All templates

Starters

Mock a GraphQL API

The data envelope, and the errors envelope most clients forget to handle.

2 routes · live immediately · no account needed

GraphQL answers with 200 even when things go wrong: failures come back inside an errors array alongside a possibly-partial data object. That is the case client code routinely forgets, because a happy-path mock never produces it. Send operationName FailingQuery and this mock returns the spec's error shape — message, locations, path — so the branch actually gets written.

What you get

POST/graphql200 OK
POST/graphqlconditional200 OK

Example response

POST /graphql

{
  "data": {
    "hero": {
      "name": "R2-D2",
      "heroFriends": [
        {
          "id": "1000",
          "name": "Luke Skywalker"
        },
        {
          "id": "1002",
          "name": "Han Solo"
        }
      ]
    }
  }
}

Good for

  • Build a GraphQL client before the schema is finished
  • Test the errors-with-200 path that REST-shaped error handling misses
  • Prototype partial-data rendering deterministically