Manuals / API Testing / Ch 10

E · AdvancedAdvanced45 min read

10. GraphQL testing basics

API Testing · 44 pages source format

Many teams use GraphQL. Testing differs from REST — queries, mutations, errors array, and no over-fetching assertions.

What you'll learn

  • Query vs mutation
  • GraphQL errors format
  • Postman GraphQL
  • When REST vs GraphQL tests differ

First GraphQL query

POST to /graphql with { "query": "{ users { id name } }" }. Single endpoint, typed schema.

Do this now

Use Postman GraphQL mode or curl against a public GraphQL API (e.g. SpaceX demo).

Clear?

Assert data and errors

Response: { data: {...}, errors: [...] }. Assert both paths — partial errors are common.

Do this now

Send invalid query. Assert errors array non-empty and data null or partial.

Clear?

Strategy note

Same pyramid applies — test resolvers at unit level when possible, integration at GraphQL layer.

Do this now

Add GraphQL section to STRATEGY.md (half page).

Clear?

Checklist