-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): Fix RequestContext race condition causing null activeOrder
Fixes #2097. This commit alters the way we store the RequestContext object on the `req` object so that we can better target individual handlers, preventing parallel execution of queries from interfering with one another.
- Loading branch information
1 parent
bffc58a
commit f235249
Showing
7 changed files
with
144 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/core/e2e/fixtures/test-plugins/issue-2097-plugin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Query, Resolver } from '@nestjs/graphql'; | ||
import { Allow, Ctx, Permission, RequestContext, VendurePlugin } from '@vendure/core'; | ||
import gql from 'graphql-tag'; | ||
|
||
@Resolver() | ||
class TestResolver { | ||
@Query() | ||
async publicThing(@Ctx() ctx: RequestContext) { | ||
return true; | ||
} | ||
|
||
@Query() | ||
@Allow(Permission.Owner) | ||
async ownerProtectedThing(@Ctx() ctx: RequestContext) { | ||
if (ctx.authorizedAsOwnerOnly) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
@VendurePlugin({ | ||
shopApiExtensions: { | ||
schema: gql` | ||
extend type Query { | ||
publicThing: Boolean! | ||
ownerProtectedThing: Boolean! | ||
} | ||
`, | ||
resolvers: [TestResolver], | ||
}, | ||
}) | ||
export class Issue2097Plugin {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters