Skip to content

Commit

Permalink
Fixed errors. Improved READMEs
Browse files Browse the repository at this point in the history
  • Loading branch information
syrusakbary committed May 13, 2016
1 parent cd053ed commit 7801c11
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 43 deletions.
26 changes: 8 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,25 @@ Adds GraphQL support to your Flask application.

## Usage

Just create a `GraphQL` instance from `flask_graphql`
Just use the `GraphQLView` view from `flask_graphql`

```python
from flask_graphql import GraphQL
from flask_graphql import GraphQLView

app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True))

graphql_blueprint = GraphQL(app, schema=schema)
```

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

## Customization

This package provides the following Views:
* `GraphQLView`: endpoint for expose the GraphQL schema
* `GraphiQLView`: Graphical Interface for operate with GraphQL easily

You can also add only the views you want to use:
```python
from flask_graphql import GraphQLView, GraphiQLView

app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema))
```

### 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.
* `root_value`: The `root_value` you want to provide to `executor.execute`.
* `default_query`: The `default_query` you want to provide to GraphiQL interface.
* `graphiql`: If `True`, may present [GraphiQL][https://github.com/graphql/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.
Expand Down
36 changes: 12 additions & 24 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,32 @@ Adds GraphQL support to your Flask application.
Usage
-----

Just create a ``GraphQL`` instance from ``flask_graphql``
Just use the ``GraphQLView`` view from ``flask_graphql``

.. code:: python
from flask_graphql import GraphQL
from flask_graphql import GraphQLView
graphql_blueprint = GraphQL(app, schema=schema)
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.

Customization
-------------

This package provides the following Views: \* ``GraphQLView``: endpoint
for expose the GraphQL schema \* ``GraphiQLView``: Graphical Interface
for operate with GraphQL easily

You can also add only the views you want to use:

.. code:: python
from flask_graphql import GraphQLView, GraphiQLView
app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema))
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.
- ``root_value``: The ``root_value`` you want to provide to
``executor.execute``.
- ``default_query``: The ``default_query`` you want to provide to
GraphiQL interface.
- ``graphiql``: If ``True``, may present
[GraphiQL][https://github.com/graphql/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
Expand All @@ -57,8 +45,8 @@ request.
def get_root_value(self, request):
return request.user
.. |Build Status| image:: https://travis-ci.org/graphql-python/graphql-flask.svg?branch=master
:target: https://travis-ci.org/graphql-python/graphql-flask
.. |Build Status| image:: https://travis-ci.org/graphql-python/flask-graphql.svg?branch=master
:target: https://travis-ci.org/graphql-python/flask-graphql
.. |Coverage Status| image:: https://coveralls.io/repos/graphql-python/graphql-flask/badge.svg?branch=master&service=github
:target: https://coveralls.io/github/graphql-python/graphql-flask?branch=master
.. |PyPI version| image:: https://badge.fury.io/py/graphql-flask.svg
Expand Down
1 change: 0 additions & 1 deletion flask_graphql/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def __init__(self, app, schema, **options):
self.blueprint = Blueprint('graphql', __name__,
template_folder='templates')

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

self.app.register_blueprint(self.blueprint)

0 comments on commit 7801c11

Please sign in to comment.