The Guild LogoThe Guild Monogram

Search docs

Search icon

Products by The Guild

Products

Hive logoHive blurred logo

Hive

Schema Registry for your GraphQL Workflows

Docs

GraphQL Inspector

Bulletproof your GraphQL

Get Started

Providing Documents#

There are few ways of providing operations and fragments (documents in general).

JavaScript and TypeScript files#

GraphQL Inspector support glob pattern.

./src/app/**/*.ts

Given example above, Inspector will search every file that matches that pattern and extract operations and fragments wrapped with gql or graphql template literal tag.

Supported extensions: .ts, .tsx, .js and .jsx

GraphQL files#

GraphQL Inspector support glob pattern.

./src/app/**/*.graphql

Given example above, Inspector will search every file that matches that pattern and extract operations and fragments.

Supported extensions: .graphql, .graphqls and .gql.

⚠️ Remember to wrap a glob pattern with quotes: "./src/app/**/*.graphql" ⚠️

Programmatic API#

If you are using programmatic API, you might find @graphql-tools/load package useful for loading documents. Learn more here.

const { validate } = require('@graphql-inspector/core') const { loadDocuments } = require('@graphql-tools/load') const { GraphQLFileLoader } = require('@graphql-tools/graphql-file-loader') const graphql = require('graphql') const documents = loadDocuments('./src/**/*.graphql', { loaders: [new GraphQLFileLoader()] }) // Convert documents to the format expected by "validate" function const sources = documents.map(doc => { return new graphql.Source(graphql.print(doc.document), doc.location) }) const invalidDocuments = validate(schema, sources)