graphql-python / flask-graphql

Adds GraphQL support to your Flask application.
MIT License
1.32k stars 140 forks source link

Graphene v3 breaks flask-graphql #87

Closed thaonc97 closed 3 years ago

thaonc97 commented 3 years ago

It seems like upgrading graphene to v3 has broken the compatibility of flask-graphql. Here is the traceback:

File "C:\Users\Admin\.conda\envs\pnd-graphene-3\lib\site-packages\flask\cli.py", line 240, in locate_app
__import__(module_name)
File "D:\aap\aap\app.py", line 3, in <module>
from flask_graphql import GraphQLView
File "C:\Users\Admin\.conda\envs\pnd-graphene-3\lib\site-packages\flask_graphql\__init__.py", line 1, in <module>
from .blueprint import GraphQL
File "C:\Users\Admin\.conda\envs\pnd-graphene-3\lib\site-packages\flask_graphql\blueprint.py", line 5, in <module>
from .graphqlview import GraphQLView
File "C:\Users\Admin\.conda\envs\pnd-graphene-3\lib\site-packages\flask_graphql\graphqlview.py", line 7, in <module>
from graphql_server import (HttpQueryError, default_format_error,
File "C:\Users\Admin\.conda\envs\pnd-graphene-3\lib\site-packages\graphql_server\__init__.py", line 18, in <module>
from graphql import get_default_backend
ImportError: cannot import name 'get_default_backend' from 'graphql' (C:\Users\Admin\.conda\envs\pnd-graphene-3\lib\site-packages\graphql\__init__.py)

Edit: Add minimal code to reproduce

from graphene import ObjectType, String, Schema

from flask import Flask
from flask_graphql import GraphQLView

class Query(ObjectType):

    work_plz = String()

    def resolve_work_plz(root, info):
        return 'It worked'

schema = Schema(query=Query)

app = Flask(__name__)

app.add_url_rule('/graphql', view_func=GraphQLView.as_view(
    'graphql',
    schema=schema,
    graphiql=True,
))

if __name__ == '__main__':
    app.run()

I'm currently using:

Flask==1.1.2
Flask-GraphQL==2.0.1
graphene==3.0
graphql-core==3.1.6
thaonc97 commented 3 years ago

nvm I changed to graphql-server and it works now