Skip to content

Commit

Permalink
feat: prisma 5.4 serverless driver adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
mmachatschek committed Oct 4, 2023
1 parent 60357b7 commit 7584fe7
Show file tree
Hide file tree
Showing 65 changed files with 1,227 additions and 1,494 deletions.
4 changes: 2 additions & 2 deletions examples/assets-local/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
},
"dependencies": {
"@keystone-6/core": "^5.0.0",
"@prisma/client": "^4.16.2"
"@prisma/client": "^5.4.0"
},
"devDependencies": {
"prisma": "^4.16.2",
"prisma": "^5.4.0",
"typescript": "~5.0.0"
}
}
4 changes: 2 additions & 2 deletions examples/assets-s3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
},
"dependencies": {
"@keystone-6/core": "^5.0.0",
"@prisma/client": "^4.16.2",
"@prisma/client": "^5.4.0",
"dotenv": "^16.0.0"
},
"devDependencies": {
"prisma": "^4.16.2",
"prisma": "^5.4.0",
"typescript": "~5.0.0"
}
}
4 changes: 2 additions & 2 deletions examples/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"dependencies": {
"@keystone-6/auth": "^7.0.0",
"@keystone-6/core": "^5.0.0",
"@prisma/client": "^4.16.2"
"@prisma/client": "^5.4.0"
},
"devDependencies": {
"prisma": "^4.16.2",
"prisma": "^5.4.0",
"typescript": "~5.0.0"
}
}
4 changes: 2 additions & 2 deletions examples/cloudinary/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
"dependencies": {
"@keystone-6/cloudinary": "workspace:^",
"@keystone-6/core": "^5.7.0",
"@prisma/client": "^4.16.2",
"@prisma/client": "^5.4.0",
"dotenv": "^16.0.0"
},
"devDependencies": {
"prisma": "^4.16.2",
"prisma": "^5.4.0",
"typescript": "~5.0.0"
}
}
4 changes: 2 additions & 2 deletions examples/custom-admin-ui-logo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
"dependencies": {
"@keystone-6/core": "^5.0.0",
"@keystone-ui/core": "^5.0.1",
"@prisma/client": "^4.16.2",
"@prisma/client": "^5.4.0",
"next": "^13.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"prisma": "^4.16.2",
"prisma": "^5.4.0",
"typescript": "~5.0.0"
}
}
4 changes: 2 additions & 2 deletions examples/custom-admin-ui-navigation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
},
"dependencies": {
"@keystone-6/core": "^5.0.0",
"@prisma/client": "^4.16.2",
"@prisma/client": "^5.4.0",
"react": "^18.2.0"
},
"devDependencies": {
"prisma": "^4.16.2",
"prisma": "^5.4.0",
"typescript": "~5.0.0"
}
}
4 changes: 2 additions & 2 deletions examples/custom-admin-ui-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
"dependencies": {
"@keystone-6/core": "^5.0.0",
"@keystone-ui/core": "^5.0.1",
"@prisma/client": "^4.16.2",
"@prisma/client": "^5.4.0",
"next": "^13.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"prisma": "^4.16.2",
"prisma": "^5.4.0",
"typescript": "~5.0.0"
}
}
4 changes: 2 additions & 2 deletions examples/custom-field-view/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
"@keystone-ui/core": "^5.0.1",
"@keystone-ui/fields": "^7.1.1",
"@keystone-ui/icons": "^6.0.1",
"@prisma/client": "^4.16.2",
"@prisma/client": "^5.4.0",
"next": "^13.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"prisma": "^4.16.2",
"prisma": "^5.4.0",
"typescript": "~5.0.0"
}
}
4 changes: 2 additions & 2 deletions examples/custom-field/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"dependencies": {
"@keystone-6/core": "^5.0.0",
"@keystone-ui/fields": "^7.1.1",
"@prisma/client": "^4.16.2"
"@prisma/client": "^5.4.0"
},
"devDependencies": {
"prisma": "^4.16.2",
"prisma": "^5.4.0",
"typescript": "~5.0.0"
}
}
4 changes: 2 additions & 2 deletions examples/custom-id/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"dependencies": {
"@keystone-6/core": "^5.0.0",
"@paralleldrive/cuid2": "^2.2.1",
"@prisma/client": "^4.16.2"
"@prisma/client": "^5.4.0"
},
"devDependencies": {
"prisma": "^4.16.2",
"prisma": "^5.4.0",
"tsx": "^3.9.0",
"typescript": "~5.0.0"
}
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-output-paths/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
},
"dependencies": {
"@keystone-6/core": "^5.0.0",
"@prisma/client": "^4.16.2",
"@prisma/client": "^5.4.0",
"next": "^13.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"prisma": "^4.16.2",
"prisma": "^5.4.0",
"typescript": "~5.0.0"
}
}
28 changes: 28 additions & 0 deletions examples/custom-prisma-driver-adapter/README.md
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.
31 changes: 31 additions & 0 deletions examples/custom-prisma-driver-adapter/keystone.ts
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,
});
24 changes: 24 additions & 0 deletions examples/custom-prisma-driver-adapter/package.json
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"
}
}
7 changes: 7 additions & 0 deletions examples/custom-prisma-driver-adapter/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 7584fe7

Please sign in to comment.