Docs
Essentials
Validate Documents

Validate Documents

Validate documents against a schema and looks for deprecated usage.

Validate

Usage

Run the following command:

graphql-inspector validate DOCUMENTS SCHEMA

Example

graphql-inspector validate './documents/*.graphql' http://localhost:3000/graphql

Arguments

  • DOCUMENTS - a glob pattern that points to GraphQL Documents / Operations
  • SCHEMA - point to a schema

Flags

  • -d, --deprecated - Fail on deprecated usage (default: false)
  • --noStrictFragments - Do not fail on duplicated fragment names (default: false)
  • --apollo - Support Apollo directives (@client and @connection) (default: false)
  • --keepClientFields <b> - Keeps the fields with @client, but removes @client directive from them - works only with combination of --apollo (default: false)
  • --method - method on url schema pointers (default: POST)
  • --federation - Support Apollo Federation directives (default: false)
  • --aws - Support AWS Appsync directives and scalar types (default: false)
  • --maxDepth <n> - Fail when operation depth exceeds maximum depth (default: false)
  • --maxAliasCount <n> - Fail when alias count (including the referenced fragments) exceeds maximum alias count (default: false)
  • --maxDirectiveCount <n> - Fail when directive count in a operation (including the referenced fragments) exceeds maximum directive count (default: false)
  • --maxTokenCount <n> - Fail when token count (including the referenced fragments) exceeds maximum token count (default: false)
  • --filter <s> - show warnings and errors only for a file (or a list of files)
  • --silent - silent mode
  • --output <s> - writes errors to a file
  • --onlyErrors - shows only errors
  • --relativePaths - displays file paths relative to process cwd
  • -r, --require <s> - require a module
  • -t, --token <s> - an access token
  • -h, --header <s> - set http header (--header 'Auth: Basic 123')

Output

A list of errors found in documents. A second list with every deprecated usage.

When there's at least one error or a deprecated usage (when --deprecated flag is enabled), the process fails.

Last updated on September 12, 2022