Skip to main content

graphql-mocks

Highlight

Use Highlight to flexibly select parts of the schema to mock and modify

Mock

Flexibly define resolver behavior with wrappers and middlewares to cover even the most complex mocking scenarios

Store

Persist mutations and control stateful data with a graphql-paper in-memory store

Resolve

Resolve GraphQL queries in Node and the Browser with the provided GraphQLHandler

Network

Write once, use everywhere. Network Handlers bring your mocks to node, the browser, and more.

CLI

Use the gqlmocks CLI to fetch remote schemas, generate boilerplate and run mock servers on localhost.

Demo

⚠️ Warning: No servers are used, or harmed, in the resolving of these GraphQL queries

To quickly show a few of the features in action here we have:

  • Setting up a GraphQL query handler and making a query
  • Using graphql-paper package, an in-memory graphql store, which allows stateful queries (try a mutation and see the change persist in subsequent queries)
  • An embedded logWrapper highlighted on all root-level Query resolvers for logging. Check the developer console for helpful logging after each query run.

Go ahead and do a few queries and mutations (see changes persist)

GraphiQL
Query Variables
Request Headers

The Code