8000 Updated readme · graphql-python/sanic-graphql@5274ee9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5274ee9

Browse files
committed
Updated readme
1 parent df82b0a commit 5274ee9

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ This will add `/graphql` endpoint to your app.
3030
In order to pass Sanic’s eventloop to GraphQL’s `AsyncioExecutor`, use `before_start` listener:
3131

3232
```python
33-
def before_start(app, loop):
33+
@app.listener('before_server_start')
34+
def init_graphql(app, loop):
3435
app.add_route(GraphQLView.as_view(schema=Schema, executor=AsyncioExecutor(loop=loop)), '/graphql')
35-
36-
app.run(before_start=before_start)
3736
```
3837

3938
### Supported options
@@ -42,7 +41,7 @@ app.run(before_start=before_start)
4241
- `context`: A value to pass as the `context` to the `graphql()` function. By default is set to `dict` with request object at key `request`.
4342
- `root_value`: The `root_value` you want to provide to `executor.execute`.
4443
- `pretty`: Whether or not you want the response to be pretty printed JSON.
45-
- `executor`: The `Executor` that you want to use to execute queries. If an `AsyncExecutor` instance is provided, performs queries asynchronously within executor’s loop.
44+
- `executor`: The `Executor` that you want to use to execute queries. If an `AsyncioExecutor` instance is provided, performs queries asynchronously within executor’s loop.
4645
- `graphiql`: If `True`, may present [GraphiQL] when loaded directly from a browser (a useful tool for debugging and exploration).
4746
- `graphiql_template`: Inject a Jinja template string to customize GraphiQL.
4847
- `jinja_env`: Sets jinja environment to be used to process GraphiQL template. If Jinja’s async mode is enabled (by `enable_async=True`), uses

README.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ In order to pass Sanic's eventloop to GraphQL's ``AsyncioExecutor``, use ``befor
3030

3131
.. code:: python
3232
33-
def before_start(app, loop):
33+
@app.listener('before_server_start')
34+
def init_graphql(app, loop):
3435
app.add_route(GraphQLView.as_view(schema=Schema, executor=AsyncioExecutor(loop=loop)), '/graphql')
3536
36-
app.run(before_start=before_start)
37-
3837
3938
Supported options
4039
~~~~~~~~~~~~~~~~~
@@ -47,7 +46,7 @@ Supported options
4746
``executor.execute``.
4847
- ``pretty``: Whether or not you want the response to be pretty printed
4948
JSON.
50-
- ``executor``: The ``Executor`` that you want to use to execute queries. If an ``AsyncExecutor`` instance is provided,
49+
- ``executor``: The ``Executor`` that you want to use to execute queries. If an ``AsyncioExecutor`` instance is provided,
5150
performs queries asynchronously within executor's loop.
5251
- ``graphiql``: If ``True``, may present
5352
`GraphiQL <https://github.com/graphql/graphiql>`__ when loaded

0 commit comments

Comments
 (0)
0