Skip to content

Commit dfd863d

Browse files
committed
docs: update readme with v3-beta notes
1 parent 5f79ab8 commit dfd863d

File tree

1 file changed

+39
-7
lines changed

1 file changed

+39
-7
lines changed

README.md

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,58 @@ Adds GraphQL support to your Flask application.
2121
Just use the `GraphQLView` view from `flask_graphql`
2222

2323
```python
24+
from flask import Flask
2425
from flask_graphql import GraphQLView
2526

26-
app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True))
27+
from schema import schema
28+
29+
app = Flask(__name__)
30+
31+
app.add_url_rule('/graphql', view_func=GraphQLView.as_view(
32+
'graphql',
33+
schema=schema,
34+
graphiql=True,
35+
))
2736

2837
# Optional, for adding batch query support (used in Apollo-Client)
29-
app.add_url_rule('/graphql/batch', view_func=GraphQLView.as_view('graphql', schema=schema, batch=True))
38+
app.add_url_rule('/graphql/batch', view_func=GraphQLView.as_view(
39+
'graphql',
40+
schema=schema,
41+
batch=True
42+
))
43+
44+
if __name__ == '__main__':
45+
app.run()
3046
```
3147

32-
This will add `/graphql` and `/graphiql` endpoints to your app.
48+
This will add `/graphql` endpoint to your app and enable the GraphiQL IDE.
49+
50+
### Special Note for Graphene v3
51+
52+
If you are using the `Schema` type of [Graphene](https://github.com/graphql-python/graphene) library, be sure to use the `graphql_schema` attribute to pass as schema on the `GraphQLView` view. Otherwise, the `GraphQLSchema` from `graphql-core` is the way to go.
53+
54+
More info at [Graphene v3 release notes](https://github.com/graphql-python/graphene/wiki/v3-release-notes#graphene-schema-no-longer-subclasses-graphqlschema-type) and [GraphQL-core 3 usage](https://github.com/graphql-python/graphql-core#usage).
55+
56+
57+
### Supported options for GraphQLView
3358

34-
### Supported options
3559
* `schema`: The `GraphQLSchema` object that you want the view to execute when it gets a valid request.
36-
* `context`: A value to pass as the `context` to the `graphql()` function.
37-
* `root_value`: The `root_value` you want to provide to `executor.execute`.
60+
* `context`: A value to pass as the `context_value` to graphql `execute` function. By default is set to `dict` with request object at key `request`.
61+
* `root_value`: The `root_value` you want to provide to graphql `execute`.
3862
* `pretty`: Whether or not you want the response to be pretty printed JSON.
39-
* `executor`: The `Executor` that you want to use to execute queries.
4063
* `graphiql`: If `True`, may present [GraphiQL](https://github.com/graphql/graphiql) when loaded directly from a browser (a useful tool for debugging and exploration).
64+
* `graphiql_version`: The graphiql version to load. Defaults to **"1.0.3"**.
4165
* `graphiql_template`: Inject a Jinja template string to customize GraphiQL.
66+
* `graphiql_html_title`: The graphiql title to display. Defaults to **"GraphiQL"**.
4267
* `batch`: Set the GraphQL view as batch (for using in [Apollo-Client](http://dev.apollodata.com/core/network.html#query-batching) or [ReactRelayNetworkLayer](https://github.com/nodkz/react-relay-network-layer))
4368
* `middleware`: A list of graphql [middlewares](http://docs.graphene-python.org/en/latest/execution/middleware/).
69+
* `encode`: the encoder to use for responses (sensibly defaults to `graphql_server.json_encode`).
70+
* `format_error`: the error formatter to use for responses (sensibly defaults to `graphql_server.default_format_error`.
71+
* `subscriptions`: The GraphiQL socket endpoint for using subscriptions in graphql-ws.
72+
* `headers`: An optional GraphQL string to use as the initial displayed request headers, if not provided, the stored headers will be used.
73+
* `default_query`: An optional GraphQL string to use when no query is provided and no stored query exists from a previous session. If not provided, GraphiQL will use its own default query.
74+
* `header_editor_enabled`: An optional boolean which enables the header editor when true. Defaults to **false**.
75+
* `should_persist_headers`: An optional boolean which enables to persist headers to storage when true. Defaults to **false**.
4476

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy