graphql-python / flask-graphql

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

Using Flask-GraphQL and Flask-SQLAlchemy together? #14

Open remingtonc opened 7 years ago

remingtonc commented 7 years ago

Based on the tutorial setup and personal testing, it doesn't appear that these two methods work in tandem. Any examples of these interoperating? Or should I switch to raw SQLAlchemy to support GraphQL?

remingtonc commented 7 years ago

Moving issue to graphene-sqlalchemy as it is more applicable.

syrusakbary commented 7 years ago

@remingtonc This might help https://github.com/graphql-python/graphene-sqlalchemy/tree/master/examples/flask_sqlalchemy :)

remingtonc commented 7 years ago

@syrusakbary Thank you! That is the tutorial I have been following, however I am attempting to use Flask-SQLAlchemy instead of SQLAlchemy alone. It does not appear to work out of the box when modeling using the convenience of Flask-SQLAlchemy.

This isn't a tremendous issue because I can always convert over to just SQLAlchemy, but it would be nice if they worked together. I could easily be wrong, and hope I am :)

I set the session:

schema = graphene.Schema()
schema.execute(context_value={'session': db.session})

On query: { "errors": [ { "message": "'NoneType' object has no attribute 'fields'" } ], "data": null }

nbyodai commented 7 years ago

@remingtonc I ran into this recently, any update since you reported? thanks