Pass the field value as input to another field. The syntax to reference the field value is: $ (i.e. the symbol for a variable in GraphQL), followed by __ and the field alias or name.
For instance, the value from field excerpt is referenced as $__excerpt, and postTitle: title is referenced as $__postTitle.
The response from the second field can itself be used as input to another field:
The response will be:
The field also cannot be referenced from a directive argument (for that, use @passOnwards):
Directive @passOnwards makes the field's resolved value available to subsequent directives via a dynamic variable.
In the query below, field notHasComments is composed by obtaining the value from field hasComments and calculating its opposite value. This works by:
Making the field's value available via @passOnwards; the field's value can then be input into any subsequent directive
@applyField takes the input (exported under dynamic variable $postHasComments), applies the global field not into it, and stores the result back into the field
If the post's excerpt is empty, use the title instead:
Retrieve data from an external REST endpoint, and manipulate its data to suit your requirements.
This will produce:
Using the @remove directive on externalData, we can also avoid printing the external endpoint source data in the response:
This will now produce:
Retrieve the posts for every user that mention the user's email:
Send a newsletter defining the to and from emails through the optionValue field:
Execute conditional operations based on the value of the field. In this query, users "Leo" and "Peter" get their names converted to upper case, since they are in the "special user" array, while "Martin" does not: