Common GraphQL Directives

Last updated on June 18, 2024.

A directive allows a user to decorate part of a GraphQL schema or operation with additional configurations. They can be useful to get out of situations where a user otherwise would need to do string manipulation to add and remove fields in a query. Server implementations may also add experimental features by defining completely new directives. The core GraphQL specification includes exactly two directives, which must be supported by any spec-compliant GraphQL server implementation:

  • Only include this field in the result if the argument is .
  • Skip this field if the argument is .

Use this document to guide you in using commonly-used GraphQL directives in Insites.

doc

Code example:

Arguments

include

Directs the executor to include this field or fragment only when the argument is true.

Arguments

Included when true.

skip

Directs the executor to skip this field or fragment when the argument is true.

Arguments

Skipped when true.

deprecated

Marks an element of a GraphQL schema as 'no longer supported.'

Arguments

Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by CommonMark.

specifiedBy

Exposes a URL that specifies the behaviour of this scalar.

Arguments

The URL that specifies the behaviour of this scalar.

Note

This topic is a compilation of knowledge found at Apollo GraphQL and GraphQL.org.

Reference

You may visit the following resources for more information:

Have a suggestion for this page?

Didn't quite find what you are looking for or have feedback on how we can make the content better then we would love to hear from you. Please provide us feedback and we will get back to you shortly.