feat(drizzle): abstract shared sql code to new package (#7320)
- Abstract shared sql code to a new drizzle package - Adds sqlite package, not ready to publish until drizzle patches some issues - Add `transactionOptions` to allow customizing or disabling db transactions - Adds "experimental" label to the `schemaName` property until drizzle patches an issue
This commit is contained in:
@@ -19,38 +19,44 @@ describe('Custom GraphQL', () => {
|
||||
}
|
||||
})
|
||||
|
||||
describe('Isolated Transaction ID', () => {
|
||||
it('should isolate transaction IDs between queries in the same request', async () => {
|
||||
const query = `query {
|
||||
if (!['sqlite'].includes(process.env.PAYLOAD_DATABASE || '')) {
|
||||
describe('Isolated Transaction ID', () => {
|
||||
it('should isolate transaction IDs between queries in the same request', async () => {
|
||||
const query = `query {
|
||||
TransactionID1
|
||||
TransactionID2
|
||||
}`
|
||||
const { data } = await restClient
|
||||
.GRAPHQL_POST({
|
||||
body: JSON.stringify({ query }),
|
||||
})
|
||||
.then((res) => res.json())
|
||||
// either no transactions at all or they are different
|
||||
expect(
|
||||
(data.TransactionID2 === null && data.TransactionID1 === null) ||
|
||||
data.TransactionID2 !== data.TransactionID1,
|
||||
).toBe(true)
|
||||
})
|
||||
it('should isolate transaction IDs between mutations in the same request', async () => {
|
||||
const query = `mutation {
|
||||
const { data } = await restClient
|
||||
.GRAPHQL_POST({
|
||||
body: JSON.stringify({ query }),
|
||||
})
|
||||
.then((res) => res.json())
|
||||
// either no transactions at all or they are different
|
||||
expect(
|
||||
(data.TransactionID2 === null && data.TransactionID1 === null) ||
|
||||
data.TransactionID2 !== data.TransactionID1,
|
||||
).toBe(true)
|
||||
})
|
||||
it('should isolate transaction IDs between mutations in the same request', async () => {
|
||||
const query = `mutation {
|
||||
MutateTransactionID1
|
||||
MutateTransactionID2
|
||||
}`
|
||||
const { data } = await restClient
|
||||
.GRAPHQL_POST({
|
||||
body: JSON.stringify({ query }),
|
||||
})
|
||||
.then((res) => res.json())
|
||||
// either no transactions at all or they are different
|
||||
expect(
|
||||
(data.MutateTransactionID2 === null && data.MutateTransactionID1 === null) ||
|
||||
data.MutateTransactionID2 !== data.MutateTransactionID1,
|
||||
).toBe(true)
|
||||
const { data } = await restClient
|
||||
.GRAPHQL_POST({
|
||||
body: JSON.stringify({ query }),
|
||||
})
|
||||
.then((res) => res.json())
|
||||
// either no transactions at all or they are different
|
||||
expect(
|
||||
(data.MutateTransactionID2 === null && data.MutateTransactionID1 === null) ||
|
||||
data.MutateTransactionID2 !== data.MutateTransactionID1,
|
||||
).toBe(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
} else {
|
||||
it('should not run isolated transaction ID tests for sqlite', () => {
|
||||
expect(true).toBe(true)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user