https://graphqlscalars.com/ § https://graphqlworkshop.io/ § https://www.santiagoesteva.com/ § @sesteva § For consulting, talks and training on Web/Mobile/GraphQL: [email protected]
calls 180+ 1 1 1 Under-fetching Yes No No No Over-fetching Yes No No No Flexibility No No No Yes Dev Experience N/A Swagger RAML Docs, Mocking, Playground, etc. Skills required JS Java Java JS or Java or … Dev Cost No Diff No Diff No Diff No Diff ADRs Principle 10 - Separate GraphQL Layer from Service Layer
§ at Context or Resolver or § at Data Model or § Custom Directive § Option 2: Leverage Mule Gateway with existing in- house Policy § Bonus: Rate limiting, Analytics, Security ADRs Principle 8 - Grant access to the graph on a per-client basis, and manage what and how clients can access it.
to Graphql ADRs UI dev create story Any dev fulfill Any dev update tests UI dev integrate Principle 5. The schema should be built incrementally based on actual requirements and evolve smoothly over time.
on UI/BE -> trusted § Large number of queries? § Given product use case, we anticipate low volume. § Decision: § No need for query approval workflow § No query cost based limitation ADRs Principle 8. Grant access to the graph on a per-client basis, and manage what and how clients can access it.
Unit Tests § Why lack of focus on unit tests? § GraphQL should delegate logic to Service Layer. § We chose to cover negative scenarios as part of our integration tests § Tools § Test Runner: JEST § Enable GraphQL env without an HTTP Server: apollo- server-testing § Mocking http requests: NOCK or JEST.mock § Validate Data Structures: Jest custom matchers § Mock Context and allow DataSource mocking: Custom Helper ADRs
§ wrap resolvers? wrap RestDataSource? § tracingOn + formatResponse? § apollo server plugin? § Health Check § Out of the box: /.well-known/apollo/server-health § BYO: onHealthCheck <Promise> ADRs Principle 9. Capture structured logs of all graph operations and leverage them as the primary tool for understanding graph usage.
(5xx HTTP codes, 1xxx WebSocket codes) § Client problems e.g. rate-limited, unauthorized, etc. (4xx HTTP codes) § The query is missing/malformed § The query fails GraphQL internal validation (syntax, schema logic, etc.) § Expected Errors § The query returns no results § The query returns partial results § Non Actionable § Unexpected Errors § An uncaught developer error occurred inside the resolve/subscribe function (e.g. poorly written database query) § An unexpected error occurred when querying underlying service (500 when requesting data from a REST api) ADRs