Comments (10)
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}))
from flask-graphql.
There seem to be changes in graphql-server-core and flask-graphql to change unit tests :
"Improved query execution using pluggable backend" in graphql-server-core e.g.:
graphql-python/graphql-server@d60b180
There is an underlying change in graphql-python/graphql-core@f6d79ab
in the commit "Modernize execute function" around graphql-core v2.1.0
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?
from 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
from flask-graphql.
Cannot speak to why they would have possibly removed it but I can say for now I just am using this to work around.
class MyGraphQLView(GraphQLView):
def get_context(self):
context = super().get_context()
context.session = db.session
return context
from flask-graphql.
@cockscomb It works perfectly thanks for sharing this
from flask-graphql.
I'm having the same problem. I tried to use context
and context_value
and neither of them works.
from flask-graphql.
same
from flask-graphql.
same
from flask-graphql.
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?
from flask-graphql.
Ah thanks! This was what I meant by "restore the old context behavior by inheritance".
from flask-graphql.
Related Issues (20)
- How to get GraphQL error objects using GraphQLView in 2.0.0? HOT 1
- No updates recently? HOT 1
- Why graphql does not return JSON?
- Incompatible with graphql-core==3.0.0 HOT 2
- Upgrade to graphql-core v3 HOT 3
- Enabling "explorer" HOT 14
- Bump graphql-core version to fix concurrency / security issues
- Flask-GraphQL now returns warnings when using `graphql-core HOT 3
- Include Altair GraphQL view HOT 2
- The embedded GraphiQL version is extremely outdated HOT 5
- Documentation on how to make an update mutation
- Header support in graphiQL interface HOT 9
- AttributeError on Graphqlview HOT 1
- CSRF Exemption? HOT 1
- which graphiql version is using? HOT 2
- Accessing query/mutation name from GraphQLView
- Graphene v3 breaks flask-graphql HOT 1
- Dependency conflicts with graphene>=3.0 HOT 2
- python 3.10+ MutableMapping ImportError HOT 1
- Error when importing flask_graphql HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flask-graphql.