@pothos/plugin-prisma 3.40.3 → 3.41.1
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.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 +3 -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 +8 -7
- 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/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 +2 -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 +8 -7
- 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 +3 -1
- package/src/util/cursors.ts +29 -15
- package/src/util/datamodel.ts +7 -5
- package/src/util/map-query.ts +12 -7
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,
|
|
@@ -161,7 +162,9 @@ function resolveIndirectInclude(
|
|
|
161
162
|
continue;
|
|
162
163
|
|
|
163
164
|
default:
|
|
164
|
-
throw new
|
|
165
|
+
throw new PothosValidationError(
|
|
166
|
+
`Unsupported selection kind ${(selection as { kind: string }).kind}`,
|
|
167
|
+
);
|
|
165
168
|
}
|
|
166
169
|
}
|
|
167
170
|
}
|
|
@@ -206,7 +209,9 @@ function addNestedSelections(
|
|
|
206
209
|
continue;
|
|
207
210
|
|
|
208
211
|
default:
|
|
209
|
-
throw new
|
|
212
|
+
throw new PothosValidationError(
|
|
213
|
+
`Unsupported selection kind ${(selection as { kind: string }).kind}`,
|
|
214
|
+
);
|
|
210
215
|
}
|
|
211
216
|
}
|
|
212
217
|
}
|
|
@@ -226,7 +231,7 @@ function addFieldSelection(
|
|
|
226
231
|
const field = type.getFields()[selection.name.value];
|
|
227
232
|
|
|
228
233
|
if (!field) {
|
|
229
|
-
throw new
|
|
234
|
+
throw new PothosValidationError(`Unknown field ${selection.name.value} on ${type.name}`);
|
|
230
235
|
}
|
|
231
236
|
|
|
232
237
|
const fieldSelect = field.extensions?.pothosPrismaSelect as FieldSelection | undefined;
|
|
@@ -403,7 +408,7 @@ export function selectionStateFromInfo(
|
|
|
403
408
|
const state = createStateForType(type, info);
|
|
404
409
|
|
|
405
410
|
if (!isObjectType(type)) {
|
|
406
|
-
throw new
|
|
411
|
+
throw new PothosValidationError('Prisma plugin can only resolve includes for object types');
|
|
407
412
|
}
|
|
408
413
|
|
|
409
414
|
addFieldSelection(type, context, info, state, info.fieldNodes[0], []);
|
|
@@ -445,20 +450,20 @@ function normalizeInclude(path: string[], type: GraphQLNamedType) {
|
|
|
445
450
|
const normalized: { name: string; type: string }[] = [];
|
|
446
451
|
|
|
447
452
|
if (!isObjectType(currentType)) {
|
|
448
|
-
throw new
|
|
453
|
+
throw new PothosValidationError(`Expected ${currentType} to be an Object type`);
|
|
449
454
|
}
|
|
450
455
|
|
|
451
456
|
for (const fieldName of path) {
|
|
452
457
|
const field: GraphQLField<unknown, unknown> = currentType.getFields()[fieldName];
|
|
453
458
|
|
|
454
459
|
if (!field) {
|
|
455
|
-
throw new
|
|
460
|
+
throw new PothosValidationError(`Expected ${currentType} to have a field ${fieldName}`);
|
|
456
461
|
}
|
|
457
462
|
|
|
458
463
|
currentType = getNamedType(field.type);
|
|
459
464
|
|
|
460
465
|
if (!isObjectType(currentType)) {
|
|
461
|
-
throw new
|
|
466
|
+
throw new PothosValidationError(`Expected ${currentType} to be an Object type`);
|
|
462
467
|
}
|
|
463
468
|
|
|
464
469
|
normalized.push({ name: fieldName, type: currentType.name });
|