Skip to content
Console(opens in a new tab)

@include

Directs the executor to include this field or fragment only when the `if` argument is true.

Directives. This directive runs after the query has its answer. It changes what you see, not what the query reads.

Directs the executor to include this field or fragment only when the if argument is true.

Argument Type Description
if Boolean! Included when true.

FIELD, FRAGMENT_SPREAD, INLINE_FRAGMENT.

query {
search(searchInput: {
entityType: BRAND
name: "Safeway"
conditions: { limit: 1 }
}) {
... on Brand {
id
names(first: 1) @include(if: true) { edges { node { name } } }
}
}
}

Response, as returned:

{
"data": {
"search": [
{
"id": "0f26fbef-3436-4f85-8bcd-31fe12a4f99a",
"names": {
"edges": [
{
"node": {
"name": "SAFEWAY"
}
}
]
}
}
]
}
}