@pothos/plugin-prisma 3.40.2 → 3.41.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 +13 -0
- package/dts/model-loader.d.ts.map +1 -1
- package/dts/util/cursors.d.ts.map +1 -1
- package/dts/util/datamodel.d.ts.map +1 -1
- package/dts/util/map-query.d.ts.map +1 -1
- package/esm/generator.js.map +1 -1
- package/esm/model-loader.d.ts.map +1 -1
- package/esm/model-loader.js +5 -5
- package/esm/model-loader.js.map +1 -1
- package/esm/prisma-field-builder.js.map +1 -1
- package/esm/schema-builder.js +2 -2
- package/esm/schema-builder.js.map +1 -1
- package/esm/util/cursors.d.ts.map +1 -1
- package/esm/util/cursors.js +17 -17
- package/esm/util/cursors.js.map +1 -1
- package/esm/util/datamodel.d.ts.map +1 -1
- package/esm/util/datamodel.js +5 -4
- package/esm/util/datamodel.js.map +1 -1
- package/esm/util/description.js.map +1 -1
- package/esm/util/map-query.d.ts.map +1 -1
- package/esm/util/map-query.js +13 -8
- package/esm/util/map-query.js.map +1 -1
- package/esm/util/selections.js +2 -2
- package/esm/util/selections.js.map +1 -1
- package/generated.ts +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/global-types.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/model-loader.js +4 -4
- package/lib/model-loader.js.map +1 -1
- package/lib/node-ref.js.map +1 -1
- package/lib/object-ref.js.map +1 -1
- package/lib/prisma-field-builder.js.map +1 -1
- package/lib/schema-builder.js +1 -1
- package/lib/schema-builder.js.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/util/cursors.js +16 -16
- package/lib/util/cursors.js.map +1 -1
- package/lib/util/datamodel.js +5 -4
- package/lib/util/datamodel.js.map +1 -1
- package/lib/util/deep-equal.js.map +1 -1
- package/lib/util/description.js.map +1 -1
- package/lib/util/get-client.js.map +1 -1
- package/lib/util/loader-map.js.map +1 -1
- package/lib/util/map-query.js +12 -8
- package/lib/util/map-query.js.map +1 -1
- package/lib/util/relation-map.js.map +1 -1
- package/lib/util/selections.js +2 -2
- package/lib/util/selections.js.map +1 -1
- package/package.json +8 -8
- package/src/generator.ts +1 -1
- package/src/model-loader.ts +5 -5
- package/src/schema-builder.ts +2 -1
- package/src/util/cursors.ts +29 -15
- package/src/util/datamodel.ts +7 -5
- package/src/util/map-query.ts +23 -8
package/src/util/map-query.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
Kind,
|
|
15
15
|
SelectionSetNode,
|
|
16
16
|
} from 'graphql';
|
|
17
|
+
import { PothosValidationError } from '@pothos/core';
|
|
17
18
|
import {
|
|
18
19
|
FieldSelection,
|
|
19
20
|
IncludeMap,
|
|
@@ -55,7 +56,7 @@ function addTypeSelectionsForField(
|
|
|
55
56
|
pothosPrismaIndirectInclude?: IndirectInclude;
|
|
56
57
|
};
|
|
57
58
|
|
|
58
|
-
if (pothosPrismaIndirectInclude) {
|
|
59
|
+
if (pothosPrismaIndirectInclude && pothosPrismaIndirectInclude.path.length > 0) {
|
|
59
60
|
resolveIndirectInclude(
|
|
60
61
|
type,
|
|
61
62
|
info,
|
|
@@ -66,6 +67,16 @@ function addTypeSelectionsForField(
|
|
|
66
67
|
addTypeSelectionsForField(resolvedType, context, info, state, field, path);
|
|
67
68
|
},
|
|
68
69
|
);
|
|
70
|
+
} else if (pothosPrismaIndirectInclude) {
|
|
71
|
+
addTypeSelectionsForField(
|
|
72
|
+
info.schema.getType(pothosPrismaIndirectInclude.getType())!,
|
|
73
|
+
context,
|
|
74
|
+
info,
|
|
75
|
+
state,
|
|
76
|
+
selection,
|
|
77
|
+
indirectPath,
|
|
78
|
+
);
|
|
79
|
+
return;
|
|
69
80
|
}
|
|
70
81
|
|
|
71
82
|
if (!isObjectType(type)) {
|
|
@@ -151,7 +162,9 @@ function resolveIndirectInclude(
|
|
|
151
162
|
continue;
|
|
152
163
|
|
|
153
164
|
default:
|
|
154
|
-
throw new
|
|
165
|
+
throw new PothosValidationError(
|
|
166
|
+
`Unsupported selection kind ${(selection as { kind: string }).kind}`,
|
|
167
|
+
);
|
|
155
168
|
}
|
|
156
169
|
}
|
|
157
170
|
}
|
|
@@ -196,7 +209,9 @@ function addNestedSelections(
|
|
|
196
209
|
continue;
|
|
197
210
|
|
|
198
211
|
default:
|
|
199
|
-
throw new
|
|
212
|
+
throw new PothosValidationError(
|
|
213
|
+
`Unsupported selection kind ${(selection as { kind: string }).kind}`,
|
|
214
|
+
);
|
|
200
215
|
}
|
|
201
216
|
}
|
|
202
217
|
}
|
|
@@ -216,7 +231,7 @@ function addFieldSelection(
|
|
|
216
231
|
const field = type.getFields()[selection.name.value];
|
|
217
232
|
|
|
218
233
|
if (!field) {
|
|
219
|
-
throw new
|
|
234
|
+
throw new PothosValidationError(`Unknown field ${selection.name.value} on ${type.name}`);
|
|
220
235
|
}
|
|
221
236
|
|
|
222
237
|
const fieldSelect = field.extensions?.pothosPrismaSelect as FieldSelection | undefined;
|
|
@@ -393,7 +408,7 @@ export function selectionStateFromInfo(
|
|
|
393
408
|
const state = createStateForType(type, info);
|
|
394
409
|
|
|
395
410
|
if (!isObjectType(type)) {
|
|
396
|
-
throw new
|
|
411
|
+
throw new PothosValidationError('Prisma plugin can only resolve includes for object types');
|
|
397
412
|
}
|
|
398
413
|
|
|
399
414
|
addFieldSelection(type, context, info, state, info.fieldNodes[0], []);
|
|
@@ -435,20 +450,20 @@ function normalizeInclude(path: string[], type: GraphQLNamedType) {
|
|
|
435
450
|
const normalized: { name: string; type: string }[] = [];
|
|
436
451
|
|
|
437
452
|
if (!isObjectType(currentType)) {
|
|
438
|
-
throw new
|
|
453
|
+
throw new PothosValidationError(`Expected ${currentType} to be an Object type`);
|
|
439
454
|
}
|
|
440
455
|
|
|
441
456
|
for (const fieldName of path) {
|
|
442
457
|
const field: GraphQLField<unknown, unknown> = currentType.getFields()[fieldName];
|
|
443
458
|
|
|
444
459
|
if (!field) {
|
|
445
|
-
throw new
|
|
460
|
+
throw new PothosValidationError(`Expected ${currentType} to have a field ${fieldName}`);
|
|
446
461
|
}
|
|
447
462
|
|
|
448
463
|
currentType = getNamedType(field.type);
|
|
449
464
|
|
|
450
465
|
if (!isObjectType(currentType)) {
|
|
451
|
-
throw new
|
|
466
|
+
throw new PothosValidationError(`Expected ${currentType} to be an Object type`);
|
|
452
467
|
}
|
|
453
468
|
|
|
454
469
|
normalized.push({ name: fieldName, type: currentType.name });
|