Skip to content

Commit

Permalink
enable prisma previes features via keystone config (#6574)
Browse files Browse the repository at this point in the history
Co-authored-by: Tim Leslie <[email protected]>
  • Loading branch information
Nikitoring and timleslie authored Sep 19, 2021
1 parent 32c1410 commit 3ee4542
Show file tree
Hide file tree
Showing 14 changed files with 1,014 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/silly-gifts-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@keystone-next/prisma-preview-features': minor
'@keystone-next/keystone': minor
---

Enable prisma preview features via keystone config
380 changes: 380 additions & 0 deletions examples/prisma-preview-features/CHANGELOG.md

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions examples/prisma-preview-features/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Feature Example - Prisma Preview Features

This project demonstrates how to use the prisma preview features with custom queries .
It builds on the [extend-graphql-schema](../extend-graphql-schema) starter project.

## Instructions

To run this project, clone the Keystone repository locally then navigate to this directory and run:

```shell
yarn 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 query `exampleWithPrismaPreviewFeatures`.

## Features

This project demonstrates how to use the Prisma Preview Features like `orderRelation`.
23 changes: 23 additions & 0 deletions examples/prisma-preview-features/custom-schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { graphQLSchemaExtension } from '@keystone-next/keystone';

export const extendGraphqlSchema = graphQLSchemaExtension({
typeDefs: `
type Query {
exampleWithPrismaPreviewFeatures: [Task]
}
`,
resolvers: {
Query: {
exampleWithPrismaPreviewFeatures: async (root, args, context) => {
const data = await context.prisma.task.findMany({
orderBy: {
assignedTo: {
name: 'desc',
},
},
});
return data;
},
},
},
});
13 changes: 13 additions & 0 deletions examples/prisma-preview-features/keystone.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { config } from '@keystone-next/keystone';
import { lists } from './schema';
import { extendGraphqlSchema } from './custom-schema';

export default config({
db: {
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
prismaPreviewFeatures: ['orderByRelation'],
},
lists,
extendGraphqlSchema,
});
22 changes: 22 additions & 0 deletions examples/prisma-preview-features/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "@keystone-next/prisma-preview-features",
"version": "0.0.0",
"private": true,
"license": "MIT",
"scripts": {
"dev": "keystone-next dev",
"start": "keystone-next start",
"build": "keystone-next build",
"seed-data": "keystone-next --seed-data"
},
"dependencies": {
"@keystone-next/keystone": "^25.0.0"
},
"devDependencies": {
"typescript": "^4.4.3"
},
"engines": {
"node": "^12.20 || >= 14.13"
},
"repository": "https://github.com/keystonejs/keystone/tree/master/examples/prisma-preview-features"
}
Loading

0 comments on commit 3ee4542

Please sign in to comment.