Adds GraphQL support to your Flask application
Project description
Adds GraphQL support to your Flask application.
Usage
Just use the GraphQLView view from flask_graphql
from flask_graphql import GraphQLView
app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True))
# Optional, for adding batch query support (used in Apollo-Client)
app.add_url_rule('/graphql/batch', view_func=GraphQLView.as_view('graphql', schema=schema, batch=True))
This will add /graphql and /graphiql endpoints to your app.
Supported options
schema: The GraphQLSchema object that you want the view to execute when it gets a valid request.
context: A value to pass as the context to the graphql() function.
root_value: The root_value you want to provide to executor.execute.
pretty: Whether or not you want the response to be pretty printed JSON.
executor: The Executor that you want to use to execute queries.
graphiql: If True, may present GraphiQL when loaded directly from a browser (a useful tool for debugging and exploration).
graphiql_template: Inject a Jinja template string to customize GraphiQL.
batch: Set the GraphQL view as batch (for using in Apollo-Client or ReactRelayNetworkLayer)
You can also subclass GraphQLView and overwrite get_root_value(self, request) to have a dynamic root value per request.
class UserRootValue(GraphQLView):
def get_root_value(self, request):
return request.user
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file Flask-GraphQL-2.0.0.tar.gz
.
File metadata
- Download URL: Flask-GraphQL-2.0.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4e23dfd767f7028835208db0bfa7145f59467225882e6d4f560d15c09f32de8 |
|
MD5 | 72dacc65c7879d4d84d871fff5d5cf0c |
|
BLAKE2b-256 | d68c043bd1deec422d33c31961dd93d952236326b1e5bbca6d3479383360ac42 |