Skip to content

Commit 8c835ef

Browse files
committed
Updated usage instructions
1 parent f788732 commit 8c835ef

File tree

3 files changed

+87
-6
lines changed

3 files changed

+87
-6
lines changed

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
1-
# `graphql-flask`
1+
# GraphQL-Flask
22

33
[![Build Status](https://travis-ci.org/graphql-python/graphql-flask.svg?branch=master)](https://travis-ci.org/graphql-python/graphql-flask) [![Coverage Status](https://coveralls.io/repos/graphql-python/graphql-flask/badge.svg?branch=master&service=github)](https://coveralls.io/github/graphql-python/graphql-flask?branch=master) [![PyPI version](https://badge.fury.io/py/graphql-flask.svg)](https://badge.fury.io/py/graphql-flask)
44

5-
A `Flask` package that provides two main views for operate with `GraphQL`:
6-
* `GraphQLView`: endpoint for expose the GraphQL schema
7-
* `GraphiQLView`: Graphical Interface for operate with GraphQL easily
5+
Adds GraphQL support to your Flask application.
86

97
## Usage
10-
Use it like you would any other Flask View.
118

9+
Just create a `GraphQL` instance from `graphql_flask`
10+
11+
```python
12+
from graphql_flask import GraphQL
13+
14+
graphql_blueprint = GraphQL(app, schema=schema)
15+
```
16+
17+
This will add `/graphql` and `/graphiql` endpoints to your app.
18+
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:
1226
```python
1327
from graphql_flask import GraphQLView, GraphiQLView
1428

@@ -20,6 +34,7 @@ app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=sch
2034
* `pretty`: Whether or not you want the response to be pretty printed JSON.
2135
* `executor`: The `Executor` that you want to use to execute queries.
2236
* `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.
2338

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

README.rst

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
GraphQL-Flask
2+
=============
3+
4+
|Build Status| |Coverage Status| |PyPI version|
5+
6+
Adds GraphQL support to your Flask application.
7+
8+
Usage
9+
-----
10+
11+
Just create a ``GraphQL`` instance from ``graphql_flask``
12+
13+
.. code:: python
14+
15+
from graphql_flask import GraphQL
16+
17+
graphql_blueprint = GraphQL(app, schema=schema)
18+
19+
This will add ``/graphql`` and ``/graphiql`` endpoints to your app.
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 graphql_flask import GraphQLView, GraphiQLView
33+
34+
app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema))
35+
36+
Supported options
37+
~~~~~~~~~~~~~~~~~
38+
39+
- ``schema``: The ``GraphQLSchema`` object that you want the view to
40+
execute when it gets a valid request.
41+
- ``pretty``: Whether or not you want the response to be pretty printed
42+
JSON.
43+
- ``executor``: The ``Executor`` that you want to use to execute
44+
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.
49+
50+
You can also subclass ``GraphQLView`` and overwrite
51+
``get_root_value(self, request)`` to have a dynamic root value per
52+
request.
53+
54+
.. code:: python
55+
56+
class UserRootValue(GraphQLView):
57+
def get_root_value(self, request):
58+
return request.user
59+
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
62+
.. |Coverage Status| image:: https://coveralls.io/repos/graphql-python/graphql-flask/badge.svg?branch=master&service=github
63+
:target: https://coveralls.io/github/graphql-python/graphql-flask?branch=master
64+
.. |PyPI version| image:: https://badge.fury.io/py/graphql-flask.svg
65+
:target: https://badge.fury.io/py/graphql-flask

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
setup(
66
name='graphql-flask',
77
version='0.0.1',
8-
description='A Flask libarary for handle easily graphql',
8+
description='Adds GraphQL support to your Flask application',
9+
long_description=open('README.rst').read(),
910
url='https://github.com/graphql-python/graphql-flask',
1011
download_url='https://github.com/graphql-python/graphql-flask/releases',
1112
author='Syrus Akbary',

0 commit comments

Comments
 (0)