Skip to content

Commit

Permalink
Updated instructions on how to pass the context
Browse files Browse the repository at this point in the history
I had to pass the context explicitly to get the example to work
  • Loading branch information
tdamsma committed May 5, 2017
1 parent 3ccd939 commit 6d930a2
Showing 1 changed file with 4 additions and 3 deletions.
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

0 comments on commit 6d930a2

Please sign in to comment.