@include
The@includedirective may be provided for fields, fragment spreads, and inline fragments, and allows for conditional inclusion during execution as described by the if argument.
In this exampleexperimentalFieldwill be queried only if the$someTestis provided atruevalue.
query myQuery($someTest: Boolean) {
experimentalField @include(if: $someTest)
}
Neither
@skip
nor
@include
has precedence over the other. In the case that both the
@skip
and
@include
directives are provided in on the same the field or fragment, it
must
be queried only if the
@skip
condition is false
and
the
@include
condition is true. Stated conversely, the field or fragment must
not
be queried if either the
@skip
condition is true
or
the
@include
condition is false.