@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.
Files changed (41) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dts/model-loader.d.ts +1 -2
  3. package/dts/model-loader.d.ts.map +1 -1
  4. package/dts/prisma-field-builder.d.ts +10 -10
  5. package/dts/util/cursors.d.ts.map +1 -1
  6. package/dts/util/description.d.ts.map +1 -1
  7. package/esm/connection-helpers.js.map +1 -1
  8. package/esm/field-builder.js.map +1 -1
  9. package/esm/generator.js.map +1 -1
  10. package/esm/index.js.map +1 -1
  11. package/esm/model-loader.d.ts +1 -2
  12. package/esm/model-loader.d.ts.map +1 -1
  13. package/esm/model-loader.js +4 -5
  14. package/esm/model-loader.js.map +1 -1
  15. package/esm/prisma-field-builder.d.ts +10 -10
  16. package/esm/util/cursors.d.ts.map +1 -1
  17. package/esm/util/cursors.js +3 -0
  18. package/esm/util/cursors.js.map +1 -1
  19. package/esm/util/datamodel.js.map +1 -1
  20. package/esm/util/description.d.ts.map +1 -1
  21. package/esm/util/description.js.map +1 -1
  22. package/esm/util/loader-map.js.map +1 -1
  23. package/esm/util/map-query.js.map +1 -1
  24. package/lib/connection-helpers.js.map +1 -1
  25. package/lib/field-builder.js.map +1 -1
  26. package/lib/generator.js.map +1 -1
  27. package/lib/index.js.map +1 -1
  28. package/lib/model-loader.js +4 -5
  29. package/lib/model-loader.js.map +1 -1
  30. package/lib/util/cursors.js +3 -0
  31. package/lib/util/cursors.js.map +1 -1
  32. package/lib/util/datamodel.js.map +1 -1
  33. package/lib/util/description.js.map +1 -1
  34. package/lib/util/loader-map.js.map +1 -1
  35. package/lib/util/map-query.js.map +1 -1
  36. package/package.json +8 -8
  37. package/src/connection-helpers.ts +1 -1
  38. package/src/model-loader.ts +9 -10
  39. package/src/util/cursors.ts +5 -2
  40. package/src/util/description.ts +4 -3
  41. 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.0",
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": "^5.19.1"
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": "^5.19.1",
70
- "graphql": ">=16.6.0",
71
- "graphql-scalars": "^1.23.0",
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": "^5.19.1",
74
- "vitest": "^2.0.5",
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,
@@ -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 (this.delegate.findUniqueOrThrow) {
306
- this.delegate
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
- this.delegate
312
+ delegate
314
313
  .findUnique({
315
314
  rejectOnNotFound: true,
316
315
  ...selectionToQuery(state),
@@ -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
- return (id as Buffer).toString('base64');
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;
@@ -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 ? description ?? getModel(model, builder).documentation : description) ||
34
- undefined
33
+ (usePrismaDescription
34
+ ? (description ?? getModel(model, builder).documentation)
35
+ : description) || undefined
35
36
  );
36
37
  }
@@ -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