graphene icon indicating copy to clipboard operation
graphene copied to clipboard

DisableIntrospection validation rule restrict __typename queries

Open antonmyronyuk opened this issue 3 years ago • 2 comments

  • What is the current behavior? graphene.validation.disable_introspection.DisableIntrospection doesn't allow to query __typename

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem https://github.com/graphql-python/graphene/blob/9c1db0f66247893c81d681fc3152ff0955fc3cd3/docs/execution/queryvalidation.rst#disable-introspection And then do some query witth __typename

  • What is the expected behavior? Allow to query __typename field. The other way is to remove this validation rule in favour of built-in graphql NoSchemaIntrospectionCustomRule https://github.com/graphql-python/graphql-core/blob/main/src/graphql/validation/rules/custom/no_schema_introspection.py#L11

  • What is the motivation / use case for changing the behavior? __typename is important thing for Apollo client (for data caching)

  • Please tell us about your environment:

    • Version: Python 3.9, graphene 3.0b8
    • Platform: Ubuntu 20

antonmyronyuk avatar Nov 05 '21 17:11 antonmyronyuk

@antonmyronyuk could you just import this NoSchemaIntrospectionCustomRule rule and use that instead?

from graphql.validation import NoSchemaIntrospectionCustomRule
...
validation_errors = validate(
    schema=schema.graphql_schema,
    document_ast=parse('THE QUERY'),
    rules=(
        NoSchemaIntrospectionCustomRule,
    )
)

theodesp avatar Jun 14 '22 19:06 theodesp

@theodesp yes, standard NoSchemaIntrospectionCustomRule works fine

I mean graphene.validation.disable_introspection.DisableIntrospection should be fixed or replaced with standard validator to have the same behaviour

antonmyronyuk avatar Jun 15 '22 07:06 antonmyronyuk

Hey @theodesp, @antonmyronyuk, what is "THE QUERY'? Can you please explain it with an example? I want to disable introspection. What should I write here?

shahzaib-tk avatar Oct 18 '22 13:10 shahzaib-tk