Skip to content

Commit 2d52c94

Browse files
authored
Merge pull request #1 from tdamsma/patch-1
Updated instructions on how to pass the context
2 parents 3ccd939 + 6d930a2 commit 2d52c94

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@ from webob_graphql import serve_graphql_request
3333
# In summary, don't use the renderer='json' here :)
3434
)
3535
def graphql_view(request):
36-
return serve_graphql_request(request, schema)
36+
context = {'session': request.session}
37+
return serve_graphql_request(request, schema, context_value=context)
3738

3839
# Optional, for adding batch query support (used in Apollo-Client)
39-
return serve_graphql_request(request, schema, batch_enabled=True)
40+
return serve_graphql_request(request, schema, batch_enabled=True, context_value=context)
4041
```
4142

4243
### Supported options
4344
* `schema`: The `GraphQLSchema` object that you want the view to execute when it gets a valid request.
44-
* `context`: A value to pass as the `context` to the `graphql()` function.
45+
* `context_value`: A value to pass as the `context` to the `graphql()` function.
4546
* `root_value`: The `root_value` you want to provide to `executor.execute`.
4647
* `format_error`: If you want to use a custom error formatter.
4748
* `pretty`: Whether or not you want the response to be pretty printed JSON.

0 commit comments

Comments
 (0)