Skip to content

Commit 286f8ae

Browse files
sergey-komissarovprokher
authored andcommitted
Removed unnecessary items from GraphQL operation context.
1 parent 870a7bf commit 286f8ae

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

channels_graphql_ws/graphql_ws_consumer.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -579,10 +579,6 @@ async def _on_gql_start(self, op_id, payload):
579579

580580
# Prepare a context object.
581581
context = DictAsObject({})
582-
context.graphql_ws_consumer = self
583-
context.graphql_operation_id = op_id
584-
context.graphql_operation_name = op_name
585-
context.channels_consumer = self
586582
context.channels_scope = self.scope
587583
context.channel_name = self.channel_name
588584

@@ -604,7 +600,9 @@ async def unbound_root_middleware(*args, **kwds):
604600
`graphql.MiddlewareManager` accepts only unbound
605601
functions as middleware.
606602
"""
607-
return await self._on_gql_start__root_middleware(*args, **kwds)
603+
return await self._on_gql_start__root_middleware(
604+
op_id, op_name, *args, **kwds
605+
)
608606

609607
# NOTE: Middlewares order is important, root middleware
610608
# should always be the closest to the real resolver (first
@@ -900,7 +898,14 @@ async def map_source_to_response(payload: Any) -> graphql.ExecutionResult:
900898
return graphql.MapAsyncIterator(result_or_stream, map_source_to_response)
901899

902900
async def _on_gql_start__root_middleware(
903-
self, next_middleware, root, info: graphql.GraphQLResolveInfo, *args, **kwds
901+
self,
902+
operation_id: int,
903+
operation_name: str,
904+
next_middleware,
905+
root,
906+
info: graphql.GraphQLResolveInfo,
907+
*args,
908+
**kwds,
904909
):
905910
"""Root middleware injected right before resolver invocation.
906911
@@ -980,8 +985,8 @@ def wrapped_next_middleware(root, info, *args, **kwds):
980985
pretty_name,
981986
duration,
982987
self.warn_resolver_timeout,
983-
info.context.graphql_operation_name,
984-
info.context.graphql_operation_id,
988+
operation_name,
989+
operation_id,
985990
info.path,
986991
)
987992

0 commit comments

Comments
 (0)