AddValidationRules
Add graphql-core validation rules.
Example:
import strawberryfrom strawberry.extensions import AddValidationRulesfrom graphql import ValidationRule, GraphQLError
class MyCustomRule(ValidationRule): def enter_field(self, node, *args) -> None: if node.name.value == "secret_field": self.report_error(GraphQLError("Can't query field 'secret_field'"))
schema = strawberry.Schema( Query, extensions=[ AddValidationRules( [ MyCustomRule, ] ), ],)
Constructor:
Signature:
def __init__(self, validation_rules: List[Type[ASTValidationRule]]) -> None: ...
Parameters:
-
validation_rules:
- Type
-
List[Type[ASTValidationRule]]
Methods:
-
on_operation
Signature:
def on_operation(self) -> Iterator[None]:...
Attributes:
-
validation_rules:
- Type
-
List[Type[ASTValidationRule]]