/mock-external-schema

Use Apollo Server to mock an external schema

Primary LanguageJavaScript

Mock any GraphQL schema. All you need is a schema.json or the URL of a GraphQL server that has introspection enabled.

Steps:

  • Update the schema to the one you want by either:
    • Replacing schema.json, or
    • Replacing https://api.spacex.land/graphql in package.json and running npm run update-schema
  • Running npm start
  • Opening localhost:4000 and querying with Playground

Mocking docs: https://www.apollographql.com/docs/apollo-server/testing/mocking/

SpaceX query in Playground with mocked results