GraphQL directives present and future you should know about

What are GraphQL directives?

Where can GraphQL directives be used?

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

Example of an operation directive:

query GetItems @cached {
id
}

Example of a field directive:

query GetItems($shouldNotGetNames: Boolean) {
id
names @skip(if:$shouldNotGetNames)
}

What do GraphQL directives do?

Current Specification Directives

@deprecated

@skip

@include

@specifiedBy

Future Specification Directives

@defer with args

@stream with args

Hasura defined Custom Directives

@cached

Community defined Custom Directives

@rest

@dbquery

@materializer

@external

@requires(fields: _FieldSet!)

@provides(fields: _FieldSet!)

@key(fields: _FieldSet!)

@_

⚡️ Instant realtime GraphQL APIs! Connect Hasura to your database & data sources (GraphQL, REST & 3rd party API) and get a unified data access layer instantly.

⚡️ Instant realtime GraphQL APIs! Connect Hasura to your database & data sources (GraphQL, REST & 3rd party API) and get a unified data access layer instantly.