Skip to content

Instantly share code, notes, and snippets.

@genadyp
Last active November 29, 2018 09:49
Show Gist options
  • Select an option

  • Save genadyp/c967facef3c30e45f1cda1c79d2d588e to your computer and use it in GitHub Desktop.

Select an option

Save genadyp/c967facef3c30e45f1cda1c79d2d588e to your computer and use it in GitHub Desktop.
graphql

Get GraphQL whole schema query

Using graphql-cli is now the recommended workflow to get and update your schema.

The following commands will get you started:

install via NPM

npm install -g graphql-cli

Setup your .graphqlconfig file (configure endpoints + schema path)

graphql init

Download the schema from the server

graphql get-schema

You can even listen for schema changes and continuously update your schema by running:

graphql get-schema --watch

In case you just want to download the GraphQL schema, use the following approach:

The easiest way to get a GraphQL schema is using the CLI tool get-graphql-schema.

You can install it via NPM:

npm install -g get-graphql-schema

There are two ways to get your schema.

  1. GraphQL IDL format

  2. JSON introspection query format.

GraphQL IDL format

get-graphql-schema ENDPOINT_URL > schema.graphql

JSON introspection format

get-graphql-schema --json ENDPOINT_URL > schema.json

or

get-graphql-schema -j ENDPOINT_URL > schema.json

For more information you can refer to the following tutorial: How to download the GraphQL IDL Schema

Link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment