HomeToolsAbout a20k

Directives

What is it

Directives are used to provide information to the server about how a query or mutation should be executed

Decorates part of a GQL schema or operation (query/mutation) with additional configuration

type ExampleType { oldField: String @deprecated(reason: "Use `newField`") newField: String }

@include

Only returns the record on a field when the return value from the resolver passes the defined condition.

The field resolver won't run when the condition is not met.

query getUsers { users { id name @include(if: false) email role } }

Does not return the name field unless the value is false (same as skip)

@skip

@deprecated

Marks a field or enum value as deprecated, providing information about why it is deprecated.

type User { username: String password: String @deprecated(reason: "Use more secure authentication methods.") }

Custom Directives

directive @customDirective(arg: String) on FIELD type Query { exField: String @customDirective(arg: "exField") }
© VincentVanKoh