Skip to content

Commit

Permalink
Merge pull request #129 from evo-company/fix-pass-context
Browse files Browse the repository at this point in the history
fix: pass context to dispatch
  • Loading branch information
kindermax committed Sep 7, 2023
2 parents 198e0aa + 203cf76 commit aefbf68
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 6 additions & 2 deletions hiku/endpoint/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,17 @@ async def dispatch(
return list(
await gather(
*(
super(AsyncGraphQLEndpoint, self).dispatch(item)
super(AsyncGraphQLEndpoint, self).dispatch(
item, context
)
for item in data
)
)
)
else:
return await super(AsyncGraphQLEndpoint, self).dispatch(data)
return await super(AsyncGraphQLEndpoint, self).dispatch(
data, context
)


class AsyncBatchGraphQLEndpoint(AsyncGraphQLEndpoint):
Expand Down
6 changes: 4 additions & 2 deletions hiku/federation/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,12 @@ async def dispatch(
) -> SingleOrBatchedResponse:
if isinstance(data, list):
return list(
await gather(*(super().dispatch(item) for item in data))
await gather(
*(super().dispatch(item, context) for item in data)
)
)

return await super().dispatch(data)
return await super().dispatch(data, context)


class AsyncBatchFederatedGraphQLEndpoint(AsyncFederatedGraphQLEndpoint):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_source_sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,5 +356,5 @@ def check(self, src, value):
self.graph,
)

result = endpoint.dispatch({"query": src}, context={SA_ENGINE_KEY: sa_engine})
result = endpoint.dispatch({"query": src}, {SA_ENGINE_KEY: sa_engine})
check_result(result['data'], value)

0 comments on commit aefbf68

Please sign in to comment.