@pothos/plugin-prisma 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dts/model-loader.d.ts +1 -2
- package/dts/model-loader.d.ts.map +1 -1
- package/dts/prisma-field-builder.d.ts +10 -10
- package/dts/util/cursors.d.ts.map +1 -1
- package/dts/util/description.d.ts.map +1 -1
- package/esm/connection-helpers.js.map +1 -1
- package/esm/field-builder.js.map +1 -1
- package/esm/generator.js.map +1 -1
- package/esm/index.js.map +1 -1
- package/esm/model-loader.d.ts +1 -2
- package/esm/model-loader.d.ts.map +1 -1
- package/esm/model-loader.js +4 -5
- package/esm/model-loader.js.map +1 -1
- package/esm/prisma-field-builder.d.ts +10 -10
- package/esm/util/cursors.d.ts.map +1 -1
- package/esm/util/cursors.js +3 -0
- package/esm/util/cursors.js.map +1 -1
- package/esm/util/datamodel.js.map +1 -1
- package/esm/util/description.d.ts.map +1 -1
- package/esm/util/description.js.map +1 -1
- package/esm/util/loader-map.js.map +1 -1
- package/esm/util/map-query.js.map +1 -1
- package/lib/connection-helpers.js.map +1 -1
- package/lib/field-builder.js.map +1 -1
- package/lib/generator.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/model-loader.js +4 -5
- package/lib/model-loader.js.map +1 -1
- package/lib/util/cursors.js +3 -0
- package/lib/util/cursors.js.map +1 -1
- package/lib/util/datamodel.js.map +1 -1
- package/lib/util/description.js.map +1 -1
- package/lib/util/loader-map.js.map +1 -1
- package/lib/util/map-query.js.map +1 -1
- package/package.json +8 -8
- package/src/connection-helpers.ts +1 -1
- package/src/model-loader.ts +9 -10
- package/src/util/cursors.ts +5 -2
- package/src/util/description.ts +4 -3
- package/src/util/map-query.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pothos/plugin-prisma",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "A Pothos plugin for more efficient integration with prisma",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./dts/index.d.ts",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"provenance": true
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@prisma/generator-helper": "^
|
|
57
|
+
"@prisma/generator-helper": "^6.0.0"
|
|
58
58
|
},
|
|
59
59
|
"prisma": {
|
|
60
60
|
"seed": "node prisma/seed.mjs"
|
|
@@ -66,14 +66,14 @@
|
|
|
66
66
|
"typescript": ">=4.7.2"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@prisma/client": "^
|
|
70
|
-
"graphql": "
|
|
71
|
-
"graphql-scalars": "^1.
|
|
69
|
+
"@prisma/client": "^6.0.0",
|
|
70
|
+
"graphql": "^16.8.1",
|
|
71
|
+
"graphql-scalars": "^1.24.0",
|
|
72
72
|
"graphql-tag": "^2.12.6",
|
|
73
|
-
"prisma": "^
|
|
74
|
-
"vitest": "^2.
|
|
75
|
-
"@pothos/plugin-complexity": "4.1.0",
|
|
73
|
+
"prisma": "^6.0.0",
|
|
74
|
+
"vitest": "^2.1.6",
|
|
76
75
|
"@pothos/core": "4.3.0",
|
|
76
|
+
"@pothos/plugin-complexity": "4.1.0",
|
|
77
77
|
"@pothos/plugin-errors": "4.2.0",
|
|
78
78
|
"@pothos/plugin-relay": "4.3.0",
|
|
79
79
|
"@pothos/plugin-simple-objects": "4.1.0",
|
|
@@ -138,7 +138,7 @@ export function prismaConnectionHelpers<
|
|
|
138
138
|
mergeSelection(selectState, nestedSelect);
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
const baseQuery = typeof query === 'function' ? query(args, ctx) : query ?? {};
|
|
141
|
+
const baseQuery = typeof query === 'function' ? query(args, ctx) : (query ?? {});
|
|
142
142
|
|
|
143
143
|
return {
|
|
144
144
|
...baseQuery,
|
package/src/model-loader.ts
CHANGED
|
@@ -39,8 +39,6 @@ export class ModelLoader {
|
|
|
39
39
|
models: Map<object, ResolvablePromise<Record<string, unknown> | null>>;
|
|
40
40
|
}>();
|
|
41
41
|
|
|
42
|
-
delegate: PrismaDelegate;
|
|
43
|
-
|
|
44
42
|
tick = Promise.resolve();
|
|
45
43
|
|
|
46
44
|
constructor(
|
|
@@ -53,10 +51,6 @@ export class ModelLoader {
|
|
|
53
51
|
this.builder = builder;
|
|
54
52
|
this.findUnique = findUnique;
|
|
55
53
|
this.modelName = modelName;
|
|
56
|
-
this.delegate = getDelegateFromModel(
|
|
57
|
-
getClient(this.builder, this.context as never),
|
|
58
|
-
this.modelName,
|
|
59
|
-
);
|
|
60
54
|
}
|
|
61
55
|
|
|
62
56
|
static forRef<Types extends SchemaTypes>(
|
|
@@ -75,7 +69,7 @@ export class ModelLoader {
|
|
|
75
69
|
? () => {
|
|
76
70
|
throw new PothosSchemaError(`Missing findUnique for ${ref.name}`);
|
|
77
71
|
}
|
|
78
|
-
: findUnique ?? ModelLoader.getDefaultFindUnique(ref, modelName, builder),
|
|
72
|
+
: (findUnique ?? ModelLoader.getDefaultFindUnique(ref, modelName, builder)),
|
|
79
73
|
),
|
|
80
74
|
);
|
|
81
75
|
}
|
|
@@ -285,6 +279,11 @@ export class ModelLoader {
|
|
|
285
279
|
}
|
|
286
280
|
|
|
287
281
|
async initLoad(state: SelectionState, initialModel: {}) {
|
|
282
|
+
const delegate = getDelegateFromModel(
|
|
283
|
+
getClient(this.builder, this.context as never),
|
|
284
|
+
this.modelName,
|
|
285
|
+
);
|
|
286
|
+
|
|
288
287
|
const models = new Map<object, ResolvablePromise<Record<string, unknown> | null>>();
|
|
289
288
|
|
|
290
289
|
const promise = createResolvablePromise<Record<string, unknown> | null>();
|
|
@@ -302,15 +301,15 @@ export class ModelLoader {
|
|
|
302
301
|
this.staged.delete(entry);
|
|
303
302
|
|
|
304
303
|
for (const [model, { resolve, reject }] of entry.models) {
|
|
305
|
-
if (
|
|
306
|
-
|
|
304
|
+
if (delegate.findUniqueOrThrow) {
|
|
305
|
+
delegate
|
|
307
306
|
.findUniqueOrThrow({
|
|
308
307
|
...selectionToQuery(state),
|
|
309
308
|
where: { ...(this.findUnique(model as Record<string, unknown>, this.context) as {}) },
|
|
310
309
|
} as never)
|
|
311
310
|
.then(resolve as () => {}, reject);
|
|
312
311
|
} else {
|
|
313
|
-
|
|
312
|
+
delegate
|
|
314
313
|
.findUnique({
|
|
315
314
|
rejectOnNotFound: true,
|
|
316
315
|
...selectionToQuery(state),
|
package/src/util/cursors.ts
CHANGED
|
@@ -178,7 +178,10 @@ export function serializeID(id: unknown, dataType: string) {
|
|
|
178
178
|
case 'Json':
|
|
179
179
|
return JSON.stringify(id);
|
|
180
180
|
case 'Byte':
|
|
181
|
-
|
|
181
|
+
if (id instanceof Uint8Array) {
|
|
182
|
+
return Buffer.from(id).toString('base64');
|
|
183
|
+
}
|
|
184
|
+
return (id as Buffer | Uint8Array).toString('base64');
|
|
182
185
|
default:
|
|
183
186
|
return String(id);
|
|
184
187
|
}
|
|
@@ -284,7 +287,7 @@ export function wrapConnectionResult<T extends {}>(
|
|
|
284
287
|
) {
|
|
285
288
|
const gotFullResults = results.length === Math.abs(take);
|
|
286
289
|
const hasNextPage = args.before ? true : args.last ? false : gotFullResults;
|
|
287
|
-
const hasPreviousPage = args.after ? true : args.before ?? args.last ? gotFullResults : false;
|
|
290
|
+
const hasPreviousPage = args.after ? true : (args.before ?? args.last) ? gotFullResults : false;
|
|
288
291
|
const nodes = gotFullResults
|
|
289
292
|
? results.slice(take < 0 ? 1 : 0, take < 0 ? results.length : -1)
|
|
290
293
|
: results;
|
package/src/util/description.ts
CHANGED
|
@@ -14,7 +14,7 @@ export function getFieldDescription<Types extends SchemaTypes>(
|
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
16
|
(usePrismaDescription
|
|
17
|
-
? description ?? getFieldData(model, builder, fieldName).documentation
|
|
17
|
+
? (description ?? getFieldData(model, builder, fieldName).documentation)
|
|
18
18
|
: description) || undefined
|
|
19
19
|
);
|
|
20
20
|
}
|
|
@@ -30,7 +30,8 @@ export function getModelDescription<Types extends SchemaTypes>(
|
|
|
30
30
|
(typeof exposeDescriptions === 'object' && exposeDescriptions?.models === true);
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
|
-
(usePrismaDescription
|
|
34
|
-
|
|
33
|
+
(usePrismaDescription
|
|
34
|
+
? (description ?? getModel(model, builder).documentation)
|
|
35
|
+
: description) || undefined
|
|
35
36
|
);
|
|
36
37
|
}
|
package/src/util/map-query.ts
CHANGED
|
@@ -547,7 +547,7 @@ function normalizeInclude(
|
|
|
547
547
|
type: GraphQLNamedType,
|
|
548
548
|
expectedType?: GraphQLNamedType,
|
|
549
549
|
): IndirectInclude {
|
|
550
|
-
let currentType = path.length > 0 ? type : expectedType ?? type;
|
|
550
|
+
let currentType = path.length > 0 ? type : (expectedType ?? type);
|
|
551
551
|
|
|
552
552
|
const normalized: { name: string; type: string }[] = [];
|
|
553
553
|
|