Skip to content

Commit 7801c11

Browse files
committed
Fixed errors. Improved READMEs
1 parent cd053ed commit 7801c11

File tree

3 files changed

+20
-43
lines changed

3 files changed

+20
-43
lines changed

README.md

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,25 @@ Adds GraphQL support to your Flask application.
66

77
## Usage
88

9-
Just create a `GraphQL` instance from `flask_graphql`
9+
Just use the `GraphQLView` view from `flask_graphql`
1010

1111
```python
12-
from flask_graphql import GraphQL
12+
from flask_graphql import GraphQLView
13+
14+
app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True))
1315

14-
graphql_blueprint = GraphQL(app, schema=schema)
1516
```
1617

1718
This will add `/graphql` and `/graphiql` endpoints to your app.
1819

19-
## Customization
20-
21-
This package provides the following Views:
22-
* `GraphQLView`: endpoint for expose the GraphQL schema
23-
* `GraphiQLView`: Graphical Interface for operate with GraphQL easily
24-
25-
You can also add only the views you want to use:
26-
```python
27-
from flask_graphql import GraphQLView, GraphiQLView
28-
29-
app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema))
30-
```
31-
3220
### Supported options
3321
* `schema`: The `GraphQLSchema` object that you want the view to execute when it gets a valid request.
22+
* `context`: A value to pass as the `context` to the `graphql()` function.
23+
* `root_value`: The `root_value` you want to provide to `executor.execute`.
3424
* `pretty`: Whether or not you want the response to be pretty printed JSON.
3525
* `executor`: The `Executor` that you want to use to execute queries.
36-
* `root_value`: The `root_value` you want to provide to `executor.execute`.
37-
* `default_query`: The `default_query` you want to provide to GraphiQL interface.
26+
* `graphiql`: If `True`, may present [GraphiQL][https://github.com/graphql/graphiql] when loaded directly
27+
from a browser (a useful tool for debugging and exploration).
3828

3929
You can also subclass `GraphQLView` and overwrite `get_root_value(self, request)` to have a dynamic root value
4030
per request.

README.rst

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,32 @@ Adds GraphQL support to your Flask application.
88
Usage
99
-----
1010

11-
Just create a ``GraphQL`` instance from ``flask_graphql``
11+
Just use the ``GraphQLView`` view from ``flask_graphql``
1212

1313
.. code:: python
1414
15-
from flask_graphql import GraphQL
15+
from flask_graphql import GraphQLView
1616
17-
graphql_blueprint = GraphQL(app, schema=schema)
17+
app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True))
1818
1919
This will add ``/graphql`` and ``/graphiql`` endpoints to your app.
2020

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-
3621
Supported options
3722
~~~~~~~~~~~~~~~~~
3823

3924
- ``schema``: The ``GraphQLSchema`` object that you want the view to
4025
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``.
4130
- ``pretty``: Whether or not you want the response to be pretty printed
4231
JSON.
4332
- ``executor``: The ``Executor`` that you want to use to execute
4433
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).
4937

5038
You can also subclass ``GraphQLView`` and overwrite
5139
``get_root_value(self, request)`` to have a dynamic root value per
@@ -57,8 +45,8 @@ request.
5745
def get_root_value(self, request):
5846
return request.user
5947
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
6250
.. |Coverage Status| image:: https://coveralls.io/repos/graphql-python/graphql-flask/badge.svg?branch=master&service=github
6351
:target: https://coveralls.io/github/graphql-python/graphql-flask?branch=master
6452
.. |PyPI version| image:: https://badge.fury.io/py/graphql-flask.svg

flask_graphql/blueprint.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ def __init__(self, app, schema, **options):
1212
self.blueprint = Blueprint('graphql', __name__,
1313
template_folder='templates')
1414

15-
default_query = options.pop('default_query', None)
1615
app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema, **options))
1716

1817
self.app.register_blueprint(self.blueprint)

0 commit comments

Comments
 (0)