Providing Schema
There are a few options to provide your schema in GraphQL Inspector.
JavaScript And TypeScript File
GraphQL Inspector accepts CommonJS and ESModules
// Example for loading and merging multiple .graphql files into a single schema
const { makeExecutableSchema } = require('@graphql-tools/schema')
const { loadFilesSync } = require('@graphql-tools/load-files')
const typeDefs = loadFilesSync('**/*.graphql')
module.exports = makeExecutableSchema({ typeDefs })If you need to transpile a file, use --require option of the CLI:
graphql-inspector introspect ./schema.ts --require ts-node/registerGraphQL File
Files with those extensions: .graphql, .graphqls or .gql are supported by GraphQL Inspector.
graphql-inspector diff ./old-schema.graphql ./new-schema.gqlJSON File
A JSON file with introspection results can also be provided:
graphql-inspector diff ./old-schema.json ./new-schema.jsonGraphQL Endpoint
GraphQL Inspector can also introspect your GraphQL server:
graphql-inspector diff http://api.com/graphql ./new-schema.jsonGit Repository
Get GraphQL Schema file from any branch or commit of your git repository:
git:origin/branch:path/to/fileFor example, you want to get schema.graphql from origin/master:
git:origin/master:./schema.graphqlGitHub Repository
Yes, GraphQL Inspector can also do that, here’s the pattern:
github:owner/name#ref:path/to/filegithub- stays there, it tells Inspector we want to use GitHubowner- your GitHub username or organizationname- repository’s nameref- can be the name of a branch or commit shapath/to/file- where Inspector can find the GraphQL file
For example, we want to fetch a .graphql file from master branch of this sample repository:
github:kamilkisiela/graphql-inspector-example#master:./schema.graphql --token 'github-token-here'GitHub Loader requires a GitHub token to be defined!
Programmatic API
If you are using programmatic API, you might find @graphql-tools/load package useful for loading schemas. Learn more
here.