A great way to mock your GraphQL API (or extend an existing API) is through GraphQL Faker.
It can act as a proxy between your existing API and your app making it really easy to try out new use cases and develop your frontend and backend in parallel.
Installation
To use it, first install it through NPM:
npm install -g graphql-faker
Usage
Now you can either create a completely new GraphQL api through:
graphql-faker --open
Or extend an existing API:
graphql-faker ./ext-swapi.graphql --extend http://swapi.apis.guru
Now you can open up the editor at http://localhost:9002/editor/ and start using faker directives in our GraphQL schema. You can use the @fake
directive to specify how to fake data, @listLength
to specify number of returned array items and the @examples directive to provide concrete examples:
Save the model. Now you can browse to http://localhost:9002/graphql and start exploring your fake GraphQL schema.