-
-
Notifications
You must be signed in to change notification settings - Fork 577
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the Bug
RN extensions can be singleton instances meaning that the execution context can change during
lifepsan hook execution (if you have parallel operaitons running) :
async def test_execution_context_distinct_on_parallel_execution():
class EnsureDistinctExtension(SchemaExtension):
def __init__(self) -> None:
...
async def on_operation(self) -> AsyncIterator[None]:
query = self.execution_context.query
yield
assert self.execution_context.query == query
@strawberry.type
class Query:
@strawberry.field
async def foo(self) -> str:
await asyncio.sleep(0.01)
return "pong"
@strawberry.field
async def bar(self) -> str:
await asyncio.sleep(0.02)
return "pong"
schema = strawberry.Schema(query=Query, extensions=[EnsureDistinctExtension()])
query_foo = "query foo { foo }"
query_bar = "query bar { bar }"
for _ in range(10):
results = await asyncio.gather(*[schema.execute(query_foo), schema.execute(query_bar)])
for res in results:
assert not res.errors
I want to remove the execution_context from the extension instance and provide it as an argument to each hook
what do you guys think?
original discussion on discord
excpt0, nburns, notypecheck and StephenKappel
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working