Skip to main content

Directives

Directives provide a way to describe alternate runtime execution and type validation behavior in a GraphQL document. They can annotate schema elements or control query execution.

@include
Link copied!

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

Locations: FIELD, FRAGMENT_SPREAD, INLINE_FRAGMENT

directive @include(
if: Boolean!
) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT

Arguments:

ArgumentTypeDefaultDescription
ifBoolean!Included when true.

@skip
Link copied!

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

Locations: FIELD, FRAGMENT_SPREAD, INLINE_FRAGMENT

directive @skip(
if: Boolean!
) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT

Arguments:

ArgumentTypeDefaultDescription
ifBoolean!Skipped when true.

@deprecated
Link copied!

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

Locations: FIELD_DEFINITION, ARGUMENT_DEFINITION, INPUT_FIELD_DEFINITION, ENUM_VALUE

directive @deprecated(
reason: String = "No longer supported"
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | ENUM_VALUE

Arguments:

ArgumentTypeDefaultDescription
reasonString"No longer supported"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
Link copied!

Exposes a URL that specifies the behavior of this scalar.

Locations: SCALAR

directive @specifiedBy(
url: String!
) on SCALAR

Arguments:

ArgumentTypeDefaultDescription
urlString!The URL that specifies the behavior of this scalar.