graphql-python / gql

A GraphQL client in Python

Home Page:https://gql.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tests failing with graphql-core pre-release version 3.3.0a3

leszekhanusz opened this issue · comments

make tests results:

FAILED tests/custom_scalars/test_money.py::test_custom_scalar_subscribe_in_input_variable_values_serialized - TypeError: object async_generator can't be used in 'await' expression
FAILED tests/starwars/test_subscription.py::test_subscription_support - TypeError: object async_generator can't be used in 'await' expression
FAILED tests/starwars/test_subscription.py::test_subscription_support_using_client - TypeError: object async_generator can't be used in 'await' expression
FAILED tests/starwars/test_subscription.py::test_subscription_support_using_client_invalid_field - TypeError: object ExecutionResult can't be used in 'await' expression

I'm curious why graphql-core was bumped to 3.3.0 alpha. This is causing a problem for my project because I need the HTTPX transport, but graphql-core 3.3.0a conflicts with apischema. This is the stack trace apischema throws:

    from apischema import ValidationError, deserialize  # type: ignore
/Volumes/workspace/my-project/.venv/lib/python3.11/site-packages/apischema/__init__.py:71: in <module apischema>
    ???
<frozen importlib._bootstrap>:1178: in _find_and_load
    ???
<frozen importlib._bootstrap>:1149: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:690: in _load_unlocked
    ???
/Volumes/workspace/my-project/.venv/lib/python3.11/site-packages/apischema/graphql/__init__.py:14: in <module apischema.graphql>
    ???
<frozen importlib._bootstrap>:1178: in _find_and_load
    ???
<frozen importlib._bootstrap>:1149: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:690: in _load_unlocked
    ???
/Volumes/workspace/my-project/.venv/lib/python3.11/site-packages/apischema/graphql/relay/__init__.py:15: in <module apischema.graphql.relay>
    ???
<frozen importlib._bootstrap>:1178: in _find_and_load
    ???
<frozen importlib._bootstrap>:1149: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:690: in _load_unlocked
    ???
/Volumes/workspace/my-project/.venv/lib/python3.11/site-packages/apischema/graphql/relay/global_identification.py:21: in <module apischema.graphql.relay.global_identification>
    ???
<frozen importlib._bootstrap>:1178: in _find_and_load
    ???
<frozen importlib._bootstrap>:1149: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:690: in _load_unlocked
    ???
/Volumes/workspace/my-project/.venv/lib/python3.11/site-packages/apischema/graphql/schema.py:485: in <module apischema.graphql.schema>
    ???
/Volumes/workspace/my-project/.venv/lib/python3.11/site-packages/apischema/graphql/schema.py:487: in InputSchemaBuilder
    ???
E   AttributeError: module 'graphql.type.definition' has no attribute 'graphql_input_types'

Unfortunately my project management framework poetry is a stickler about dependency resolution with no built-in mechanism for overriding, but if I go into my virtualenv shell and manually replace graphql-core 3.3.0a3 with 3.2.3, the error resolves, my unit tests pass, the gql client seems to work fine at first glance, I can establish an async session with my HTTPX transport, call connect_async() and authenticate to my service, and apischema is happy again.

I think the "graphql-core>=3.3.0a2,<3.4" in gql is in fact problematic, since there can be breaking changes between alpha versions of graphql-core. Better to either stick to "graphql-core>=3.2,<3.3" or to a fixed 3.3 alpha version that is known to be compatible. Once a stable 3.3 version is released, "graphql-core>=3.3,<3.4" should be fine. Another option would be to make gql compatible with both core 3.2 and the latest 3.3 alpha, but this will require some case distinctions. The best option would be to make a stable version of gql that is compatible with core 3.2 and a beta version of gql that is compatible with the latest core 3.3 alpha.

But the more problematic issue here is apischema, since it does not impose a limit for the graphql-core version at all. They should restrict graphql-core to the compatible minor versions and also create a pre-realase that is compatible with the latest graphql-core. @kstech-roadie you should raise the issue there if you need apischema - as far as I see it's not a dependency of gql.

The best option would be to make a stable version of gql that is compatible with core 3.2 and a beta version of gql that is compatible with the latest core 3.3 alpha.

Well, that's what we have now.
The current official stable release (non pre-release version) of gql is v3.4.1, which sticks to graphql-core 3.2.x, but it does not include the httpx transport yet.

In fact gql cannot make a new stable release in the current conditions until graphql-core release its stable release too, which itself depends upon graphql-js

Another option would be to backport most of the recent commits in the gql master branch into the 3.4.x branch and create a stable 3.4.2 version with httpx transport and 3.2.x graphql-core, but this is annoying and does not really respect semver.

Then everything looks fine to me on this end and only apischema should be fixed/updated.

I appreciate the eyes on this. I actually ended up solving my problem by removing gql from pyproject.toml and vendorizing with python-vendorize. Initial testing looks good!