How to write mocks https://www.apollographql.com/docs/graphql-tools/mocking.html
Install
yarn global add graphql-mock-server
or
yarn add --dev graphql-mock-server
Usage
graphql-mock-server ./schema.graphql -p 4000
gms ./schema.graphql -p 4000
Basic example
; const mock = id: '1' name: 'Foo' id: '2' name: 'Baz' ; const data = ; // Set mock; // Reset mock;
Accessing arguments in mock resolvers
Since the mock functions on fields are actually just GraphQL resolvers, you can use arguments and context in them as well:
// the number of friends in the list now depends on numPages numPages * PAGE_SIZE