Skip to content

Updated instructions on how to pass the context #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ from webob_graphql import serve_graphql_request
# In summary, don't use the renderer='json' here :)
)
def graphql_view(request):
return serve_graphql_request(request, schema)
context = {'session': request.session}
return serve_graphql_request(request, schema, context_value=context)

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

### 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.
* `context_value`: A value to pass as the `context` to the `graphql()` function.
* `root_value`: The `root_value` you want to provide to `executor.execute`.
* `format_error`: If you want to use a custom error formatter.
* `pretty`: Whether or not you want the response to be pretty printed JSON.
Expand Down