mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-16 19:40:39 +03:00
commit
9c1db0f662
|
@ -22,6 +22,7 @@ Usage
|
||||||
Here is how you would implement depth-limiting on your schema.
|
Here is how you would implement depth-limiting on your schema.
|
||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
from graphql import validate, parse
|
from graphql import validate, parse
|
||||||
from graphene import ObjectType, Schema, String
|
from graphene import ObjectType, Schema, String
|
||||||
from graphene.validation import depth_limit_validator
|
from graphene.validation import depth_limit_validator
|
||||||
|
@ -37,7 +38,7 @@ Here is how you would implement depth-limiting on your schema.
|
||||||
# will not be executed.
|
# will not be executed.
|
||||||
|
|
||||||
validation_errors = validate(
|
validation_errors = validate(
|
||||||
schema=schema,
|
schema=schema.graphql_schema,
|
||||||
document_ast=parse('THE QUERY'),
|
document_ast=parse('THE QUERY'),
|
||||||
rules=(
|
rules=(
|
||||||
depth_limit_validator(
|
depth_limit_validator(
|
||||||
|
@ -58,6 +59,7 @@ Usage
|
||||||
Here is how you would disable introspection for your schema.
|
Here is how you would disable introspection for your schema.
|
||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
from graphql import validate, parse
|
from graphql import validate, parse
|
||||||
from graphene import ObjectType, Schema, String
|
from graphene import ObjectType, Schema, String
|
||||||
from graphene.validation import DisableIntrospection
|
from graphene.validation import DisableIntrospection
|
||||||
|
@ -72,7 +74,7 @@ Here is how you would disable introspection for your schema.
|
||||||
# introspection queries will not be executed.
|
# introspection queries will not be executed.
|
||||||
|
|
||||||
validation_errors = validate(
|
validation_errors = validate(
|
||||||
schema=schema,
|
schema=schema.graphql_schema,
|
||||||
document_ast=parse('THE QUERY'),
|
document_ast=parse('THE QUERY'),
|
||||||
rules=(
|
rules=(
|
||||||
DisableIntrospection,
|
DisableIntrospection,
|
||||||
|
@ -92,6 +94,7 @@ reason. Here is an example query validator that visits field definitions in Grap
|
||||||
if any of those fields are blacklisted:
|
if any of those fields are blacklisted:
|
||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
from graphql import GraphQLError
|
from graphql import GraphQLError
|
||||||
from graphql.language import FieldNode
|
from graphql.language import FieldNode
|
||||||
from graphql.validation import ValidationRule
|
from graphql.validation import ValidationRule
|
||||||
|
|
Loading…
Reference in New Issue
Block a user