Skip to content
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

Thread request context through to GraphQL executor #10

Closed
wants to merge 1 commit into from

Conversation

bendemaree
Copy link
Contributor

@bendemaree bendemaree commented Feb 24, 2018

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:

import graphene


class Query(graphene.ObjectType):
    noop = graphene.String()


class Subscription(graphene.ObjectType):
    ping = graphene.String(required=True)

    async def resolve_ping(root, info):
        print(info.context)
        yield "pong"

    async def resolve_player_statistics(root, info):
        pass


schema = graphene.Schema(query=Query, subscription=Subscription)

and (using WsLibSubscriptionServer):

async def handle_subscription(ws, path):
    await subscription_server.handle(ws, request_context={"foo": "bar"})

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

@SmileyChris
Copy link
Contributor

Fixed

Sign up for free to 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