Skip to content

Commit

Permalink
Add context.transaction for interactive Prisma transactions when u…
Browse files Browse the repository at this point in the history
…sing a Keystone `context` (#9122)
  • Loading branch information
dcousens authored Apr 30, 2024
1 parent 64f7220 commit e0aecbb
Show file tree
Hide file tree
Showing 14 changed files with 664 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .changeset/add-transactions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-6/core': minor
---

Adds `context.transaction` for interactive transactions when using a `context`
18 changes: 18 additions & 0 deletions examples/transactions/keystone.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { config } from '@keystone-6/core'
import { fixPrismaPath } from '../example-utils'
import { lists, extendGraphqlSchema } from './schema'

export default config({
db: {
provider: 'sqlite',
url: process.env.DATABASE_URL ?? 'file:./keystone-example.db',
enableLogging: ['query', 'info', 'warn', 'error'],

// WARNING: this is only needed for our monorepo examples, don't do this
...fixPrismaPath,
},
lists,
graphql: {
extendGraphqlSchema,
}
})
19 changes: 19 additions & 0 deletions examples/transactions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@keystone-6/example-transactions",
"private": true,
"license": "MIT",
"scripts": {
"dev": "keystone dev",
"start": "keystone start",
"build": "keystone build",
"postinstall": "keystone postinstall"
},
"dependencies": {
"@keystone-6/core": "workspace:^",
"@prisma/client": "^5.0.0"
},
"devDependencies": {
"prisma": "^5.0.0",
"typescript": "~5.0.0"
}
}
7 changes: 7 additions & 0 deletions examples/transactions/sandbox.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"template": "node",
"container": {
"startScript": "keystone dev",
"node": "16"
}
}
Loading

0 comments on commit e0aecbb

Please sign in to comment.