strawberry.extensions.MaxTokensLimiter
Add a validator to limit the number of tokens in a GraphQL document.
Example:
import strawberryfrom strawberry.extensions import MaxTokensLimiter
schema = strawberry.Schema(Query, extensions=[MaxTokensLimiter(max_token_count=1000)])
The following things are counted as tokens:
- various brackets: "{", "}", "(", ")"
- colon :
- words
Not counted:
- quotes
Constructor:
Initialize the MaxTokensLimiter.
Signature:
def __init__(self, max_token_count: int) -> None: ...
Parameters:
-
max_token_count:
The maximum number of tokens allowed in a GraphQL document.
- Type
-
int
Methods:
-
on_operation
Signature:
def on_operation(self) -> Iterator[None]:...
Attributes:
-
max_token_count: