Describe the bug
gql 4.0.0 allows graphql-core>=3.2,<3.3, but schema introspection fails with graphql-core 3.2.6 when the backend introspection response contains directive location DIRECTIVE_DEFINITION.
Updating only graphql-core to 3.2.11 fixes the issue.
Relevant stack trace:
KeyError: 'DIRECTIVE_DEFINITION'
During handling of the above exception, another exception occurred:
TypeError: deprecated locations must be specified as a collection of DirectiveLocation enum values.
File ".../gql/client.py", line 1265, in fetch_schema
self.client._build_schema_from_introspection(execution_result)
File ".../gql/client.py", line 184, in _build_schema_from_introspection
self.schema = build_client_schema(self.introspection)
File ".../graphql/utilities/build_client_schema.py", line 357, in build_directive
return GraphQLDirective(...)
File ".../graphql/type/directives.py", line 71, in <genexpr>
else DirectiveLocation[cast(str, value)]
To Reproduce
from gql import Client
client = Client(
transport=transport,
fetch_schema_from_transport=True,
)
with client as session:
pass
Use a backend whose introspection result contains a directive location named DIRECTIVE_DEFINITION.
Expected behavior
Either gql 4.0.0 should work with all allowed graphql-core>=3.2,<3.3 versions, or the lower bound should be raised to a version that supports this introspection result, for example:
graphql-core>=3.2.11,<3.3
Edit:
I just checked your setup.py which specifies "graphql-core>=3.3.0a3,<3.4". Weirdly, my system doesn't install that, when I upgrade to gql 4.0.0 (it kept graphql-core 3.2.6)
Even with a fresh poetry environment gql = { version = ">=4.0.0,<5.0.0", extras = ["requests"] } leads to graphql-core 3.2.11 not 3.3
System info (please complete the following information):
- OS: Windows
- Python version: 3.13
- gql version: 4.0.0
- graphql-core version: 3.2.6 fails, 3.2.11 works
Describe the bug
gql 4.0.0allowsgraphql-core>=3.2,<3.3, but schema introspection fails withgraphql-core 3.2.6when the backend introspection response contains directive locationDIRECTIVE_DEFINITION.Updating only
graphql-coreto3.2.11fixes the issue.Relevant stack trace:
To Reproduce
Use a backend whose introspection result contains a directive location named
DIRECTIVE_DEFINITION.Expected behavior
Either
gql 4.0.0should work with all allowedgraphql-core>=3.2,<3.3versions, or the lower bound should be raised to a version that supports this introspection result, for example:Edit:
I just checked your setup.py which specifies "graphql-core>=3.3.0a3,<3.4". Weirdly, my system doesn't install that, when I upgrade to gql 4.0.0 (it kept graphql-core 3.2.6)
Even with a fresh poetry environment gql = { version = ">=4.0.0,<5.0.0", extras = ["requests"] } leads to graphql-core 3.2.11 not 3.3
System info (please complete the following information):