Skip to content

Commit

Permalink
Add get_context() to prepare a context object
Browse files Browse the repository at this point in the history
  • Loading branch information
cpd67 committed Aug 15, 2023
1 parent 09a2ffd commit e74836d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions channels_graphql_ws/graphql_ws_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ async def _on_gql_start(self, op_id, payload):
context.channel_name = self.channel_name
context.graphql_operation_name = op_name
context.graphql_operation_id = op_id
context = self.get_context(context)

# Process the request with Graphene and GraphQL-core.
doc_ast, op_ast, errors = await self._on_gql_start__parse_query(
Expand Down Expand Up @@ -1230,6 +1231,12 @@ def _spawn_background_task(self, awaitable):
self._background_tasks.add(background_task)
return background_task

def get_context(self, context):
"""
Prepare the context object to use during GraphQL execution.
"""
return context

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

0 comments on commit e74836d

Please sign in to comment.