Skip to content

Commit

Permalink
Use Prisma's Node-API query engine (keystonejs#6920)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmatown authored Nov 22, 2021
1 parent bbedee8 commit 82539fa
Show file tree
Hide file tree
Showing 47 changed files with 220 additions and 175 deletions.
5 changes: 5 additions & 0 deletions .changeset/short-berries-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/keystone': major
---

Keystone now uses Prisma's Node-API Query Engine instead of the Binary Query Engine. This should improve the performance of operations using Prisma. See https://www.prisma.io/docs/concepts/components/prisma-engines/query-engine for more details.
5 changes: 5 additions & 0 deletions .changeset/ten-bags-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/keystone': patch
---

Fixed doing multiple writes at the same time on SQLite causing an timeout immediately.
5 changes: 2 additions & 3 deletions examples-staging/assets-cloud/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Post {
Expand Down
5 changes: 2 additions & 3 deletions examples-staging/assets-local/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Post {
Expand Down
5 changes: 2 additions & 3 deletions examples-staging/auth/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model User {
Expand Down
5 changes: 2 additions & 3 deletions examples-staging/basic/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model User {
Expand Down
5 changes: 2 additions & 3 deletions examples-staging/ecommerce/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model User {
Expand Down
5 changes: 2 additions & 3 deletions examples-staging/embedded-nextjs/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Post {
Expand Down
5 changes: 2 additions & 3 deletions examples-staging/graphql-api-endpoint/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource postgresql {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model User {
Expand Down
5 changes: 2 additions & 3 deletions examples-staging/roles/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Todo {
Expand Down
5 changes: 2 additions & 3 deletions examples-staging/sandbox/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Todo {
Expand Down
5 changes: 2 additions & 3 deletions examples/blog/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Post {
Expand Down
5 changes: 2 additions & 3 deletions examples/custom-admin-ui-logo/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Task {
Expand Down
5 changes: 2 additions & 3 deletions examples/custom-admin-ui-navigation/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Task {
Expand Down
5 changes: 2 additions & 3 deletions examples/custom-admin-ui-pages/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Task {
Expand Down
5 changes: 2 additions & 3 deletions examples/custom-field-view/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Task {
Expand Down
5 changes: 2 additions & 3 deletions examples/custom-field/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Post {
Expand Down
5 changes: 2 additions & 3 deletions examples/default-values/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Task {
Expand Down
5 changes: 2 additions & 3 deletions examples/document-field/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Post {
Expand Down
5 changes: 2 additions & 3 deletions examples/extend-graphql-schema-graphql-ts/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Post {
Expand Down
5 changes: 2 additions & 3 deletions examples/extend-graphql-schema-nexus/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Post {
Expand Down
5 changes: 2 additions & 3 deletions examples/extend-graphql-schema/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Post {
Expand Down
5 changes: 2 additions & 3 deletions examples/json/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Package {
Expand Down
5 changes: 2 additions & 3 deletions examples/rest-api/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Task {
Expand Down
5 changes: 2 additions & 3 deletions examples/task-manager/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Task {
Expand Down
5 changes: 2 additions & 3 deletions examples/testing/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Task {
Expand Down
5 changes: 2 additions & 3 deletions examples/virtual-field/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Post {
Expand Down
5 changes: 2 additions & 3 deletions examples/with-auth/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ datasource sqlite {
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
engineType = "binary"
provider = "prisma-client-js"
output = "node_modules/.prisma/client"
}

model Task {
Expand Down
5 changes: 4 additions & 1 deletion packages/keystone/src/lib/core/graphql-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ export const resolverError = (things: { error: Error; tag: string }[]) => {
};

export const relationshipError = (things: { error: Error; tag: string }[]) => {
const s = things.map(t => ` - ${t.tag}: ${t.error.message}`).join('\n');
const s = things
.map(t => ` - ${t.tag}: ${t.error.message}`)
.sort()
.join('\n');
return new ApolloError(
`An error occured while resolving relationship fields.\n${s}`,
'KS_RELATIONSHIP_ERROR',
Expand Down
4 changes: 1 addition & 3 deletions packages/keystone/src/lib/core/graphql-schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { GraphQLNamedType, GraphQLSchema } from 'graphql';
import { DatabaseProvider } from '../../types';
import { graphql } from '../..';
import { InitialisedList } from './types-for-lists';

Expand All @@ -8,7 +7,6 @@ import { getQueriesForList } from './queries';

export function getGraphQLSchema(
lists: Record<string, InitialisedList>,
provider: DatabaseProvider,
extraFields: {
mutation: Record<string, graphql.Field<unknown, any, graphql.OutputType, string>>;
query: Record<string, graphql.Field<unknown, any, graphql.OutputType, string>>;
Expand All @@ -30,7 +28,7 @@ export function getGraphQLSchema(
fields: Object.assign(
{},
...Object.values(lists).map(list => {
const { mutations, updateManyInput } = getMutationsForList(list, provider);
const { mutations, updateManyInput } = getMutationsForList(list);
updateManyByList[list.listKey] = updateManyInput;
return mutations;
}),
Expand Down
Loading

0 comments on commit 82539fa

Please sign in to comment.