Skip to content
Open
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
12 changes: 9 additions & 3 deletions channels_graphql_ws/graphql_ws_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,7 @@ async def _on_gql_start(self, op_id, payload):
variables = payload.get("variables", {})

# Prepare a context object.
context = DictAsObject({})
context.channels_scope = self.scope
context.channel_name = self.channel_name
context = self.get_context()
context.graphql_operation_name = op_name
context.graphql_operation_id = op_id

Expand Down Expand Up @@ -1230,6 +1228,14 @@ def _spawn_background_task(self, awaitable):
self._background_tasks.add(background_task)
return background_task

def get_context(self):
"""Prepare the context object to use during GraphQL execution."""
context = DictAsObject({})
context.channels_scope = self.scope
context.channel_name = self.channel_name
return context


@property
def _channel_layer(self):
"""Channel layer."""
Expand Down