![Gato GraphQL logo](/_next/static/media/GatoGraphQL-logo-suki-rectangular.d3bab7ee.png)
Conditional Field Manipulation
Conditional Field Manipulation
Addition of meta directives @if
and @unless
to the GraphQL schema, to conditionally execute a nested directive on the field.
In this query, users "Leo"
and "Peter"
get their names converted to upper case, while "Martin"
does not:
query {
users {
name
@passOnwards(as: "userName")
@applyField(
name: "_inArray"
arguments: {
value: $userName
array: ["Leo", "John", "Peter"]
}
passOnwardsAs: "isSpecialUser"
)
@if(
condition: $isSpecialUser
)
@strUpperCase
}
}
...producing:
{
"data": {
"users": [
{
"name": "LEO"
},
{
"name": "Martin"
},
{
"name": "PETER"
}
]
}
}