Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support nested execution contexts and contexts created in a separate async execution within the same stack #2459

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
nested async execution
  • Loading branch information
enisdenjo committed Nov 2, 2023
commit 88bc5c78833cab113192d98f531fb21ec099831e
21 changes: 21 additions & 0 deletions packages/graphql-modules/tests/execution-context.spec.ts
Original file line number Diff line number Diff line change
@@ -530,6 +530,27 @@ it('should provide context when created in separate async execution within same
destroy();
});

it('should provide context in nested async execution', async () => {
let destroy = () => {
// noop
};
await new Promise<void>((resolve) => {
destroy = executionContext.create({
getApplicationContext() {
return 'app' as any;
},
getModuleContext() {
return 'mod' as any;
},
});
resolve();
}).then(() => {
expect(executionContext.getApplicationContext()).toBe('app');
expect(executionContext.getModuleContext('')).toBe('mod');
});
destroy();
});

it('should provide nested contexts', async () => {
const createPicker = (i: number) => ({
getApplicationContext() {
Loading