Skip to content

Commit fb72d19

Browse files
authored
fix: graphql query concurrency issues (#6925)
## Description This is the beta (v3) PR for the v2 PR [here](#6857) Addresses #6800, #5108 - [x] I have read and understand the [CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md) document in this repository. ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## Checklist: - [x] I have added tests that prove my fix is effective or that my feature works - [x] Existing test suite passes locally with my changes
1 parent cd9df73 commit fb72d19

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+209
-79
lines changed

packages/db-mongodb/src/count.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const count: Count = async function count(
1212
{ collection, locale, req = {} as PayloadRequest, where },
1313
) {
1414
const Model = this.collections[collection]
15-
const options: QueryOptions = withSession(this, req.transactionID)
15+
const options: QueryOptions = await withSession(this, req)
1616

1717
let hasNearConstraint = false
1818

packages/db-mongodb/src/create.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const create: Create = async function create(
1010
{ collection, data, req = {} as PayloadRequest },
1111
) {
1212
const Model = this.collections[collection]
13-
const options = withSession(this, req.transactionID)
13+
const options = await withSession(this, req)
1414
let doc
1515
try {
1616
;[doc] = await Model.create([data], options)

packages/db-mongodb/src/createGlobal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const createGlobal: CreateGlobal = async function createGlobal(
1414
globalType: slug,
1515
...data,
1616
}
17-
const options = withSession(this, req.transactionID)
17+
const options = await withSession(this, req)
1818

1919
let [result] = (await Model.create([global], options)) as any
2020

packages/db-mongodb/src/createGlobalVersion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const createGlobalVersion: CreateGlobalVersion = async function createGlo
99
{ autosave, createdAt, globalSlug, parent, req = {} as PayloadRequest, updatedAt, versionData },
1010
) {
1111
const VersionModel = this.versions[globalSlug]
12-
const options = withSession(this, req.transactionID)
12+
const options = await withSession(this, req)
1313

1414
const [doc] = await VersionModel.create(
1515
[

packages/db-mongodb/src/createVersion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const createVersion: CreateVersion = async function createVersion(
1717
},
1818
) {
1919
const VersionModel = this.versions[collectionSlug]
20-
const options = withSession(this, req.transactionID)
20+
const options = await withSession(this, req)
2121

2222
const [doc] = await VersionModel.create(
2323
[

packages/db-mongodb/src/deleteMany.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const deleteMany: DeleteMany = async function deleteMany(
1010
) {
1111
const Model = this.collections[collection]
1212
const options = {
13-
...withSession(this, req.transactionID),
13+
...(await withSession(this, req)),
1414
lean: true,
1515
}
1616

packages/db-mongodb/src/deleteOne.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const deleteOne: DeleteOne = async function deleteOne(
1010
{ collection, req = {} as PayloadRequest, where },
1111
) {
1212
const Model = this.collections[collection]
13-
const options = withSession(this, req.transactionID)
13+
const options = await withSession(this, req)
1414

1515
const query = await Model.buildQuery({
1616
payload: this.payload,

packages/db-mongodb/src/deleteVersions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const deleteVersions: DeleteVersions = async function deleteVersions(
1010
) {
1111
const VersionsModel = this.versions[collection]
1212
const options = {
13-
...withSession(this, req.transactionID),
13+
...(await withSession(this, req)),
1414
lean: true,
1515
}
1616

packages/db-mongodb/src/find.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const find: Find = async function find(
1515
) {
1616
const Model = this.collections[collection]
1717
const collectionConfig = this.payload.collections[collection].config
18-
const options = withSession(this, req.transactionID)
18+
const options = await withSession(this, req)
1919

2020
let hasNearConstraint = false
2121

packages/db-mongodb/src/findGlobal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const findGlobal: FindGlobal = async function findGlobal(
1313
) {
1414
const Model = this.globals
1515
const options = {
16-
...withSession(this, req.transactionID),
16+
...(await withSession(this, req)),
1717
lean: true,
1818
}
1919

0 commit comments

Comments
 (0)