Skip to content

Thread request context through to GraphQL executor - #10

Closed
bendemaree wants to merge 1 commit into
graphql-python:masterfrom
bendemaree:fix/7
Closed

Thread request context through to GraphQL executor#10
bendemaree wants to merge 1 commit into
graphql-python:masterfrom
bendemaree:fix/7

Conversation

@bendemaree

@bendemareebendemaree commented Feb 24, 2018

Copy link
Copy Markdown
Contributor

This addresses the problem raised in #7; when graphql() is invoked, the current context value is not being passed to the executor (via context_value).

Here's a straightforward way to reproduce; if you run with and without the patch here, you'll see two different things printed:

importgrapheneclassQuery(graphene.ObjectType):
noop=graphene.String()
classSubscription(graphene.ObjectType):
ping=graphene.String(required=True)
asyncdefresolve_ping(root, info):
print(info.context)
yield"pong"asyncdefresolve_player_statistics(root, info):
passschema=graphene.Schema(query=Query, subscription=Subscription)

and (using WsLibSubscriptionServer):

asyncdefhandle_subscription(ws, path):
awaitsubscription_server.handle(ws, request_context={"foo": "bar"})

This will print None and {'foo': 'bar'} before and after this patch, respectively.

@SmileyChris

Copy link
Copy Markdown
Contributor

Fixed

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@bendemaree@SmileyChris