GraphQL @remove directive
The GraphQL @remove schema directive specifies conditions to remove
types and fields from validation or introspection for each transaction based on values in the API
context. For example, you can prevent specific API plans from using certain types or
fields.
Syntax
@remove(if: [String]) on
SCALAR | OBJECT | FIELD_DEFINITION |
ARGUMENT_DEFINITION | INTERFACE | UNION |
ENUM | ENUM_VALUE | INPUT_OBJECT |
INPUT_FIELD_DEFINITION
Arguments
| Argument | Type | Description |
|---|---|---|
if |
List of strings | JSONata condition that specifies the criteria for removal of a type or field from validation or introspection. |
Guidelines
When the @remove directive expressions are evaluated, the schema is modified
dynamically. The validate assembly action rejects queries that do not conform to the modified
schema.
For limitations and propagation rules, see Limitations and
propagation rules for the GraphQL @remove directive.
For more information about the API context, see Variables in the API context.
Examples
- Remove the
creditCardtype if the current API plan isbronze.type creditCard @remove(if: ["plan.name in [\"bronze\"]"]) - Remove the
creditCardtype if the current API plan is notgold, and remove the fieldcard1if 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\")"]) }