- Introduction
- Quick start
- Philosophy
- Comparison
- Default behaviors
- Limitations
- Debugging runbook
- FAQ
- Mocking HTTP
- Mocking GraphQL
- Mocking WebSocket
- Integrations
- API
- CLI
- Best practices
- Recipes
Mutations
Intercepting GraphQL mutations.
You can intercept a GraphQL mutation by defining a graphql.mutation() handler for it and matching it by the operation name:
graphql.mutation('CreateUser', ({ variables }) => { return HttpResponse.json({ data: { createUser: { id: 'abc-123', name: variables.name, }, }, }) })The request handler above will match the following GraphQL mutation made in your application:
mutation CreateUser($name: String!) { createUser(name: $name) { id name } }