@generate
The @generate directive specifies which GraphQL APIs are generated for a given type. Without it, all queries & mutations are generated except subscription.
We’re overhauling Dgraph’s docs to make them clearer and more approachable. If you notice any issues during this transition or have suggestions, please let us know.
The @generate
directive is used to specify which GraphQL APIs are generated
for a given type.
Here’s the GraphQL definition of the directive
The corresponding APIs are generated by setting the Boolean
variables inside
the @generate
directive to true
. Passing false
forbids the generation of
the corresponding APIs.
The default value of the subscription
variable is false
while the default
value of all other variables is true
. Therefore, if no @generate
directive
is specified for a type, all queries and mutations except subscription
are
generated.
Example of @generate directive
The GraphQL schema above will generate a queryPerson
query and addPerson
,
updatePerson
mutations. It won’t generate getPerson
, aggregatePerson
queries nor a deletePerson
mutation as these have been marked as false
using
the @generate
directive. Note that the updatePerson
mutation is generated
because the default value of the update
variable is true
.
Was this page helpful?