strawberry.extensions.AddValidationRules

Add graphql-core validation rules.

Example:

import strawberry
from strawberry.extensions import AddValidationRules
from 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:

  1. validation_rules:

    Type
    List[Type[ASTValidationRule]]

Methods:

Attributes:

  1. validation_rules:

    Type
    List[Type[ASTValidationRule]]