graphql-python / graphql-server

This is the core package for using GraphQL in a custom server easily
MIT License
120 stars 72 forks source link

Module is incompatible with graphql==3.2.0 #85

Closed thomascobb closed 2 years ago

thomascobb commented 2 years ago

On import (for instance when running tests) you get

___________________________________________ ERROR collecting tests/test_helpers.py ___________________________________________
ImportError while importing test module '/home/tom/Programming/graphql-server/tests/test_helpers.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_helpers.py:8: in <module>
    from graphql_server import (
graphql_server/__init__.py:15: in <module>
    from graphql.error import format_error as format_error_default
E   ImportError: cannot import name 'format_error' from 'graphql.error' (/home/tom/Programming/graphql-server/graphql-server-dev/lib/python3.8/site-packages/graphql/error/__init__.py)

It appears that format_error is now only importable from graphql.error.graphql_error and not graphql.error. It also appears to now be deprecated: https://github.com/graphql-python/graphql-core/commit/09ff14f68bdce1e9cd71decc871fd38274b01971

Would you like a PR to fix? If so, would you prefer just a change to the import path, or a dependency bump on graphql-core>=3.2.0 and use of the new method?

Also the README for graphl-core recommends using graphql-core~=3.2.0 so I could also change that.

Cito commented 2 years ago

Yes, pinning the requirement to the minor version (graphql-core~=3.2.0) would be the right thing to do.

format_error was indeed deprecated, you can use the property GraphQLError.formatted now (similar in GraphQL.js).

Cito commented 2 years ago

I have already fixed this in graphql-server 3.0.0b5,