Skip to content

alexanderlamb/flask-graphql

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask-GraphQL

Build Status Coverage Status PyPI version

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))

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).

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

About

Adds GraphQL support to your Flask application.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%