oro*_*ome 6 python graphql graphql-python
我有软件包版本
...
Flask 2.0.2
Flask-GraphQL 2.0.0
Flask-Script 2.0.6
...
graphene 3.0
graphql-core 3.1.6
graphql-relay 3.1.0
graphql-server-core 1.1.1
...
Run Code Online (Sandbox Code Playgroud)
当我import flask_graphql得到
Traceback (most recent call last):
File "/Users/Rax/Documents/Projects/Web/Sites/proj/_foo.py", line 1, in <module>
import flask_graphql
File "/Users/Rax/Documents/Projects/Coding/Python/venvs/proj/lib/python3.9/site-packages/flask_graphql/__init__.py", line 1, in <module>
from .blueprint import GraphQL
File "/Users/Rax/Documents/Projects/Coding/Python/venvs/proj/lib/python3.9/site-packages/flask_graphql/blueprint.py", line 5, in <module>
from .graphqlview import GraphQLView
File "/Users/Rax/Documents/Projects/Coding/Python/venvs/proj/lib/python3.9/site-packages/flask_graphql/graphqlview.py", line 7, in <module>
from graphql_server import (HttpQueryError, default_format_error,
File "/Users/Rax/Documents/Projects/Coding/Python/venvs/proj/lib/python3.9/site-packages/graphql_server/__init__.py", line 5, in <module>
from graphql import get_default_backend
ImportError: cannot import name 'get_default_backend' from 'graphql' (/Users/Rax/Documents/Projects/Coding/Python/venvs/proj/lib/python3.9/site-packages/graphql/__init__.py)
Run Code Online (Sandbox Code Playgroud)
我该如何避免这个错误。我需要不同的版本或版本范围吗?
An option: Downgrade.
Cost: Losing new features.
How: Pin these packages to these versions:
flask-graphql==2.0.1
graphene==2.1.9
graphene-sqlalchemy==2.3.0
Run Code Online (Sandbox Code Playgroud)
See GitHub issue: https://github.com/graphql-python/graphene-sqlalchemy/issues/380
Note: If you're trying to get the Flask example to work, replace the entire contents of graphene-sqlalchemy/examples/flask_sqlalchemy/requirements.txt with the above text.
You can test that the Flask example works with this query:
{
allEmployees {
edges {
node {
name
}
}
}
}
Run Code Online (Sandbox Code Playgroud)