-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: prisma 5.4 serverless driver adapters
- Loading branch information
1 parent
60357b7
commit 7584fe7
Showing
65 changed files
with
1,227 additions
and
1,494 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
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
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
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,28 @@ | ||
## Example Project - Extend Prisma Schema | ||
|
||
This project implements an example of mutating the Prisma Schema to: | ||
|
||
- Set the Prisma Binary Target; | ||
- Add a multi-column column unique constraint to a list; and | ||
- Add a NOT NULL relationship field | ||
|
||
These show three separate ways of mutating the Prisma Schema see `keystone.ts` and `schema.ts`. | ||
|
||
## Instructions | ||
|
||
To run this project, clone the Keystone repository locally, run `pnpm` at the root of this repository, then navigate to this directory and run: | ||
|
||
```shell | ||
pnpm dev | ||
``` | ||
|
||
This will start the Admin UI at [localhost:3000](http://localhost:3000). | ||
You can use the Admin UI to create items in your database. | ||
|
||
You can also access a GraphQL Playground at [localhost:3000/api/graphql](http://localhost:3000/api/graphql), which allows you to directly run GraphQL queries and mutations. | ||
|
||
Congratulations, you're now up and running with Keystone! 🚀 | ||
|
||
## Try it out in CodeSandbox 🧪 | ||
|
||
You can play with this example online in a web browser using the free [codesandbox.io](https://codesandbox.io/) service. To launch this example, open the URL <https://githubbox.com/keystonejs/keystone/tree/main/examples/extend-prisma-schema>. You can also fork this sandbox to make your own changes. |
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,31 @@ | ||
import { config } from '@keystone-6/core'; | ||
import { Pool, neonConfig } from '@neondatabase/serverless'; | ||
import { PrismaNeon } from '@prisma/adapter-neon'; | ||
import { WebSocket } from 'undici'; | ||
import { fixPrismaPath } from '../example-utils'; | ||
import { lists } from './schema'; | ||
|
||
export default config({ | ||
db: { | ||
provider: 'sqlite', | ||
url: process.env.DATABASE_URL || 'file:./keystone-example.db', | ||
|
||
prismaAdapter: () => { | ||
neonConfig.webSocketConstructor = WebSocket; | ||
|
||
const pool = new Pool({ connectionString: process.env.DATABASE_URL }); | ||
return new PrismaNeon(pool); | ||
}, | ||
|
||
extendPrismaSchema: (schema: any) => { | ||
return schema.replace( | ||
/(generator [^}]+)}/g, | ||
['$1previewFeatures = ["driverAdapters"]', '}'].join('\n') | ||
); | ||
}, | ||
|
||
// WARNING: this is only needed for our monorepo examples, dont do this | ||
...fixPrismaPath, | ||
}, | ||
lists, | ||
}); |
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,24 @@ | ||
{ | ||
"name": "@keystone-6/example-custom-prisma-driver-adapter", | ||
"version": "0.0.0", | ||
"private": true, | ||
"license": "MIT", | ||
"scripts": { | ||
"dev": "keystone dev", | ||
"start": "keystone start", | ||
"build": "keystone build", | ||
"postinstall": "keystone postinstall --fix" | ||
}, | ||
"dependencies": { | ||
"@keystone-6/core": "^5.2.0", | ||
"@keystone-6/fields-document": "^8.0.0", | ||
"@neondatabase/serverless": "^0.6.0", | ||
"@prisma/adapter-neon": "^5.4.0", | ||
"@prisma/client": "^5.4.0", | ||
"undici": "^5.25.0" | ||
}, | ||
"devDependencies": { | ||
"prisma": "^5.4.0", | ||
"typescript": "~5.0.0" | ||
} | ||
} |
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,7 @@ | ||
{ | ||
"template": "node", | ||
"container": { | ||
"startScript": "keystone dev", | ||
"node": "16" | ||
} | ||
} |
Oops, something went wrong.