@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.
Files changed (57) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dts/model-loader.d.ts.map +1 -1
  3. package/dts/util/cursors.d.ts.map +1 -1
  4. package/dts/util/datamodel.d.ts.map +1 -1
  5. package/dts/util/map-query.d.ts.map +1 -1
  6. package/esm/generator.js.map +1 -1
  7. package/esm/model-loader.d.ts.map +1 -1
  8. package/esm/model-loader.js +5 -5
  9. package/esm/model-loader.js.map +1 -1
  10. package/esm/prisma-field-builder.js.map +1 -1
  11. package/esm/schema-builder.js +3 -2
  12. package/esm/schema-builder.js.map +1 -1
  13. package/esm/util/cursors.d.ts.map +1 -1
  14. package/esm/util/cursors.js +17 -17
  15. package/esm/util/cursors.js.map +1 -1
  16. package/esm/util/datamodel.d.ts.map +1 -1
  17. package/esm/util/datamodel.js +5 -4
  18. package/esm/util/datamodel.js.map +1 -1
  19. package/esm/util/description.js.map +1 -1
  20. package/esm/util/map-query.d.ts.map +1 -1
  21. package/esm/util/map-query.js +8 -7
  22. package/esm/util/map-query.js.map +1 -1
  23. package/esm/util/selections.js +2 -2
  24. package/esm/util/selections.js.map +1 -1
  25. package/lib/connection-helpers.js.map +1 -1
  26. package/lib/field-builder.js.map +1 -1
  27. package/lib/generator.js.map +1 -1
  28. package/lib/global-types.js.map +1 -1
  29. package/lib/index.js.map +1 -1
  30. package/lib/model-loader.js +4 -4
  31. package/lib/model-loader.js.map +1 -1
  32. package/lib/node-ref.js.map +1 -1
  33. package/lib/object-ref.js.map +1 -1
  34. package/lib/prisma-field-builder.js.map +1 -1
  35. package/lib/schema-builder.js +2 -1
  36. package/lib/schema-builder.js.map +1 -1
  37. package/lib/types.js.map +1 -1
  38. package/lib/util/cursors.js +16 -16
  39. package/lib/util/cursors.js.map +1 -1
  40. package/lib/util/datamodel.js +5 -4
  41. package/lib/util/datamodel.js.map +1 -1
  42. package/lib/util/deep-equal.js.map +1 -1
  43. package/lib/util/description.js.map +1 -1
  44. package/lib/util/get-client.js.map +1 -1
  45. package/lib/util/loader-map.js.map +1 -1
  46. package/lib/util/map-query.js +8 -7
  47. package/lib/util/map-query.js.map +1 -1
  48. package/lib/util/relation-map.js.map +1 -1
  49. package/lib/util/selections.js +2 -2
  50. package/lib/util/selections.js.map +1 -1
  51. package/package.json +8 -8
  52. package/src/generator.ts +1 -1
  53. package/src/model-loader.ts +5 -5
  54. package/src/schema-builder.ts +3 -1
  55. package/src/util/cursors.ts +29 -15
  56. package/src/util/datamodel.ts +7 -5
  57. package/src/util/map-query.ts +12 -7
@@ -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 Error(`Unsupported selection kind ${(selection as { kind: string }).kind}`);
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 Error(`Unsupported selection kind ${(selection as { kind: string }).kind}`);
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 Error(`Unknown field ${selection.name.value} on ${type.name}`);
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 Error('Prisma plugin can only resolve includes for object types');
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 Error(`Expected ${currentType} to be an Object type`);
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 Error(`Expected ${currentType} to have a field ${fieldName}`);
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 Error(`Expected ${currentType} to be an Object type`);
466
+ throw new PothosValidationError(`Expected ${currentType} to be an Object type`);
462
467
  }
463
468
 
464
469
  normalized.push({ name: fieldName, type: currentType.name });