-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
passing context to GraphQLView no more supported? #52
Comments
I'm having the same problem. I tried to use |
same |
1 similar comment
same |
There seem to be changes in graphql-server-core and flask-graphql to change unit tests : There is an underlying change in graphql-python/graphql-core@f6d79ab This is where "context_value" is deprecated for "context" graphql-python/graphql-core@f6d79ab It looks like "context" is now not what is being passed by the user of flask-graphql, but a Request object instead. Maybe there is a name collision in flask-graphql? |
It looks like the breaking change was actually a long time ago, but was only put out in a full release recently: I don't know if the behaviour of "context_value" was meant to go away and the documentation was left unchanged? Edit: This also seems to be referenced in the last comment (made after merge) of #19 |
Is there a recommended way to do the things that were done by using context in older versions? I have seen the suggestion to restore the old context behaviour by inheritence. But I guess context was removed for a reason (btw what reason?), so there may be a better way? |
Cannot speak to why they would have possibly removed it but I can say for now I just am using this to work around.
|
Ah thanks! This was what I meant by "restore the old context behavior by inheritance". |
I found a test case of passing context. flask-graphql/tests/test_graphqlview.py Line 454 in 4183613
I succeeded passing custom context in the following way. app.add_url_rule(
'/graphql', view_func=GraphQLView.as_view(
'graphql', schema=SCHEMA, graphiql=True,
get_context=lambda: {'session': db_session})) |
@cockscomb It works perfectly thanks for sharing this |
Hi and thanks for the geat job.
With 1.4.1 version I used to pass my DB session via the
context
option of the GraphQLView as still mentioned in the README (which should be updated).Below is an exemple of what I was doing:
It seems this is no more possible and I can't figure out how to pass the DB session to the GraphQLView. Any information and/or updated doc would be nice.
Any solution to continue passing DB session via the GraphQLView (or by any other way allowing to pass it at execution time) would be perfect.
EDIT: for an undocumented but working solution see @cockscomb 's comment
The text was updated successfully, but these errors were encountered: