Catch the highlights of GraphQLConf 2023! Click for recordings. Or check out our recap blog post.
Docs
Commands
Coverage

Coverage (Documents & Schema)

Schema coverage is based on documents. Find out how many times types and fields are used in your application.

Coverage

Coverage - Usage

Run the following command:

graphql-inspector coverage DOCUMENTS SCHEMA

Arguments

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

Flags

  • -s, --silent- Do not render any stats in the terminal (default: false)
  • -w, --write <s> - Write a file with coverage stats (disabled by default)
  • -d, --deprecated - Fail on deprecated usage (default: false)
  • -r, --require <s> - require a module
  • -t, --token <s> - an access token
  • -h, --header <s> - set http header (--header 'Auth: Basic 123')
  • --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)

Output

Depending on enabled flags, a printed GraphQL Schema with stats per each field and overall stats, a JSON file with data.

Examples

Compare your local schema against a remote server:

graphql-inspector coverage example/documents/post.graphql example/schemas/new-valid.graphql

Statistics

  • Types covered: This shows the percentage of types in your schema that have been covered by your tests. In your case, you have achieved 100% coverage for types, which means that all types in your schema have been tested.
  • Types covered fully: This shows the percentage of types that have been fully covered by your tests, meaning that all fields in those types have been tested. In your case, you have not achieved 100% coverage for fully covered types, as the percentage is at 0%.
  • Fields covered: This shows the percentage of fields in your schema that have been covered by your tests. In your case, you have achieved 50% coverage for fields, which means that only half of the fields in your schema have been tested.
  • Total Queries: This shows the total number of queries in your schema that have been tested.
  • Total Mutations: This shows the total number of mutations in your schema that have been tested.
  • Total Subscriptions: This shows the total number of subscriptions in your schema that have been tested.

CoverageStats