@remove
directive
The @remove
GraphQL schema directive specifies conditions for removing
types and fields from validation or introspection for each transaction based on values in the API
context.
For example, you can prevent specific Plans from using certain types or fields. For more information on the API context, see API Connect context variables.
Note: The
@remove
directive dynamically modifies the schema so that queries that do
not conform to the schema, after any @remove
directives have been evaluated, would
be rejected by a validate
policy.- Syntax
@remove(if: [String]) on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
- Arguments
-
Argument name Type Description if
List of strings JSONata condition that specifies the criteria for removal of a type or field from validation or introspection. - Limitations and propagation rules
- For limitations and propagation rules, see Limitations and
propagation rules for the GraphQL
@remove
directive. - Example 1
- Remove the
creditCard
type if the current API plan isbronze
.type creditCard @remove(if: ["plan.name in [\"bronze\"]"])
- Example 2
- Remove the
creditCard
type if the current API plan is notgold
, and remove the fieldcard1
if the API plan isbronze
.type creditCard @remove(if: ["$not(plan.name = \"gold\")"]){ field1: String } type User { card1: creditCard @remove(if: ["plan.name = 'bronze'", "$not(plan.name = \gold\")"]) }