@@ -8,44 +8,32 @@ Adds GraphQL support to your Flask application.
8
8
Usage
9
9
-----
10
10
11
- Just create a ``GraphQL `` instance from ``flask_graphql ``
11
+ Just use the ``GraphQLView `` view from ``flask_graphql ``
12
12
13
13
.. code :: python
14
14
15
- from flask_graphql import GraphQL
15
+ from flask_graphql import GraphQLView
16
16
17
- graphql_blueprint = GraphQL(app , schema = schema)
17
+ app.add_url_rule( ' /graphql ' , view_func = GraphQLView.as_view( ' graphql ' , schema = schema, graphiql = True ) )
18
18
19
19
This will add ``/graphql `` and ``/graphiql `` endpoints to your app.
20
20
21
- Customization
22
- -------------
23
-
24
- This package provides the following Views: \* ``GraphQLView ``: endpoint
25
- for expose the GraphQL schema \* ``GraphiQLView ``: Graphical Interface
26
- for operate with GraphQL easily
27
-
28
- You can also add only the views you want to use:
29
-
30
- .. code :: python
31
-
32
- from flask_graphql import GraphQLView, GraphiQLView
33
-
34
- app.add_url_rule(' /graphql' , view_func = GraphQLView.as_view(' graphql' , schema = schema))
35
-
36
21
Supported options
37
22
~~~~~~~~~~~~~~~~~
38
23
39
24
- ``schema ``: The ``GraphQLSchema `` object that you want the view to
40
25
execute when it gets a valid request.
26
+ - ``context ``: A value to pass as the ``context `` to the ``graphql() ``
27
+ function.
28
+ - ``root_value ``: The ``root_value `` you want to provide to
29
+ ``executor.execute ``.
41
30
- ``pretty ``: Whether or not you want the response to be pretty printed
42
31
JSON.
43
32
- ``executor ``: The ``Executor `` that you want to use to execute
44
33
queries.
45
- - ``root_value ``: The ``root_value `` you want to provide to
46
- ``executor.execute ``.
47
- - ``default_query ``: The ``default_query `` you want to provide to
48
- GraphiQL interface.
34
+ - ``graphiql ``: If ``True ``, may present
35
+ [GraphiQL][https://github.com/graphql/graphiql] when loaded directly
36
+ from a browser (a useful tool for debugging and exploration).
49
37
50
38
You can also subclass ``GraphQLView `` and overwrite
51
39
``get_root_value(self, request) `` to have a dynamic root value per
@@ -57,8 +45,8 @@ request.
57
45
def get_root_value (self , request ):
58
46
return request.user
59
47
60
- .. |Build Status | image :: https://travis-ci.org/graphql-python/graphql- flask.svg?branch=master
61
- :target: https://travis-ci.org/graphql-python/graphql- flask
48
+ .. |Build Status | image :: https://travis-ci.org/graphql-python/flask-graphql .svg?branch=master
49
+ :target: https://travis-ci.org/graphql-python/flask-graphql
62
50
.. |Coverage Status | image :: https://coveralls.io/repos/graphql-python/graphql-flask/badge.svg?branch=master&service=github
63
51
:target: https://coveralls.io/github/graphql-python/graphql-flask?branch=master
64
52
.. |PyPI version | image :: https://badge.fury.io/py/graphql-flask.svg
0 commit comments