@pothos/plugin-prisma 3.60.0 → 3.62.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 (73) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +19 -1
  3. package/dts/global-types.d.ts.map +1 -1
  4. package/dts/prisma-field-builder.d.ts +2 -2
  5. package/dts/prisma-field-builder.d.ts.map +1 -1
  6. package/dts/types.d.ts +6 -6
  7. package/dts/types.d.ts.map +1 -1
  8. package/dts/util/map-query.d.ts.map +1 -1
  9. package/esm/connection-helpers.js +1 -2
  10. package/esm/connection-helpers.js.map +1 -1
  11. package/esm/field-builder.js +14 -11
  12. package/esm/field-builder.js.map +1 -1
  13. package/esm/generator.js.map +1 -1
  14. package/esm/global-types.d.ts.map +1 -1
  15. package/esm/global-types.js.map +1 -1
  16. package/esm/model-loader.js +8 -4
  17. package/esm/model-loader.js.map +1 -1
  18. package/esm/prisma-field-builder.d.ts +2 -2
  19. package/esm/prisma-field-builder.d.ts.map +1 -1
  20. package/esm/prisma-field-builder.js +12 -11
  21. package/esm/prisma-field-builder.js.map +1 -1
  22. package/esm/types.d.ts +6 -6
  23. package/esm/types.d.ts.map +1 -1
  24. package/esm/util/cursors.js +18 -10
  25. package/esm/util/cursors.js.map +1 -1
  26. package/esm/util/deep-equal.js +4 -5
  27. package/esm/util/deep-equal.js.map +1 -1
  28. package/esm/util/description.js +2 -4
  29. package/esm/util/description.js.map +1 -1
  30. package/esm/util/map-query.d.ts.map +1 -1
  31. package/esm/util/map-query.js +15 -24
  32. package/esm/util/map-query.js.map +1 -1
  33. package/lib/connection-helpers.js +4 -5
  34. package/lib/connection-helpers.js.map +1 -1
  35. package/lib/field-builder.js +14 -11
  36. package/lib/field-builder.js.map +1 -1
  37. package/lib/generator.js +3 -1
  38. package/lib/generator.js.map +1 -1
  39. package/lib/index.js +14 -12
  40. package/lib/index.js.map +1 -1
  41. package/lib/model-loader.js +8 -4
  42. package/lib/model-loader.js.map +1 -1
  43. package/lib/object-ref.js +3 -3
  44. package/lib/object-ref.js.map +1 -1
  45. package/lib/prisma-field-builder.js +12 -11
  46. package/lib/prisma-field-builder.js.map +1 -1
  47. package/lib/schema-builder.js +3 -1
  48. package/lib/schema-builder.js.map +1 -1
  49. package/lib/util/cursors.js +37 -29
  50. package/lib/util/cursors.js.map +1 -1
  51. package/lib/util/datamodel.js +12 -12
  52. package/lib/util/datamodel.js.map +1 -1
  53. package/lib/util/deep-equal.js +4 -5
  54. package/lib/util/deep-equal.js.map +1 -1
  55. package/lib/util/description.js +2 -4
  56. package/lib/util/description.js.map +1 -1
  57. package/lib/util/loader-map.js +3 -3
  58. package/lib/util/loader-map.js.map +1 -1
  59. package/lib/util/map-query.js +18 -27
  60. package/lib/util/map-query.js.map +1 -1
  61. package/lib/util/relation-map.js +3 -3
  62. package/lib/util/relation-map.js.map +1 -1
  63. package/lib/util/selections.js +9 -9
  64. package/lib/util/selections.js.map +1 -1
  65. package/lib/util/usage.js +6 -6
  66. package/lib/util/usage.js.map +1 -1
  67. package/package.json +9 -9
  68. package/src/field-builder.ts +9 -7
  69. package/src/generator.ts +5 -5
  70. package/src/global-types.ts +12 -12
  71. package/src/prisma-field-builder.ts +21 -17
  72. package/src/types.ts +9 -8
  73. package/src/util/map-query.ts +30 -28
@@ -134,6 +134,7 @@ function resolveIndirectInclude(
134
134
  includePath: { type?: string; name: string }[],
135
135
  path: string[],
136
136
  resolve: (type: GraphQLNamedType, field: FieldNode, path: string[]) => void,
137
+ expectedType = type,
137
138
  ) {
138
139
  if (includePath.length === 0) {
139
140
  resolve(type, selection as FieldNode, path);
@@ -149,6 +150,7 @@ function resolveIndirectInclude(
149
150
  switch (sel.kind) {
150
151
  case Kind.FIELD:
151
152
  if (
153
+ expectedType.name === type.name &&
152
154
  !fieldSkipped(info, sel) &&
153
155
  sel.name.value === include.name &&
154
156
  (isObjectType(type) || isInterfaceType(type))
@@ -166,19 +168,15 @@ function resolveIndirectInclude(
166
168
  }
167
169
  continue;
168
170
  case Kind.FRAGMENT_SPREAD:
169
- if (
170
- !include.type ||
171
- info.fragments[sel.name.value].typeCondition.name.value === include.type
172
- ) {
173
- resolveIndirectInclude(
174
- include.type ? info.schema.getType(include.type)! : type,
175
- info,
176
- info.fragments[sel.name.value],
177
- includePath,
178
- path,
179
- resolve,
180
- );
181
- }
171
+ resolveIndirectInclude(
172
+ info.schema.getType(info.fragments[sel.name.value].typeCondition.name.value)!,
173
+ info,
174
+ info.fragments[sel.name.value],
175
+ includePath,
176
+ path,
177
+ resolve,
178
+ include.type ? info.schema.getType(include.type)! : expectedType,
179
+ );
182
180
 
183
181
  continue;
184
182
 
@@ -191,6 +189,7 @@ function resolveIndirectInclude(
191
189
  includePath,
192
190
  path,
193
191
  resolve,
192
+ include.type ? info.schema.getType(include.type)! : expectedType,
194
193
  );
195
194
  }
196
195
 
@@ -211,11 +210,15 @@ function addNestedSelections(
211
210
  state: SelectionState,
212
211
  selections: SelectionSetNode,
213
212
  indirectPath: string[],
213
+ expectedType = type,
214
214
  ) {
215
215
  let parentType = type;
216
216
  for (const selection of selections.selections) {
217
217
  switch (selection.kind) {
218
218
  case Kind.FIELD:
219
+ if (expectedType.name !== type.name) {
220
+ continue;
221
+ }
219
222
  addFieldSelection(type, context, info, state, selection, indirectPath);
220
223
 
221
224
  continue;
@@ -223,13 +226,6 @@ function addNestedSelections(
223
226
  parentType = info.schema.getType(
224
227
  info.fragments[selection.name.value].typeCondition.name.value,
225
228
  )! as GraphQLObjectType;
226
- if (
227
- isObjectType(type)
228
- ? parentType.name !== type.name
229
- : parentType.extensions?.pothosPrismaModel !== type.extensions.pothosPrismaModel
230
- ) {
231
- continue;
232
- }
233
229
 
234
230
  addNestedSelections(
235
231
  parentType,
@@ -238,6 +234,9 @@ function addNestedSelections(
238
234
  state,
239
235
  info.fragments[selection.name.value].selectionSet,
240
236
  indirectPath,
237
+ parentType.extensions?.pothosPrismaModel === type.extensions.pothosPrismaModel
238
+ ? parentType
239
+ : expectedType,
241
240
  );
242
241
 
243
242
  continue;
@@ -246,15 +245,18 @@ function addNestedSelections(
246
245
  parentType = selection.typeCondition
247
246
  ? (info.schema.getType(selection.typeCondition.name.value) as GraphQLObjectType)
248
247
  : type;
249
- if (
250
- isObjectType(type)
251
- ? parentType.name !== type.name
252
- : parentType.extensions?.pothosPrismaModel !== type.extensions.pothosPrismaModel
253
- ) {
254
- continue;
255
- }
256
248
 
257
- addNestedSelections(parentType, context, info, state, selection.selectionSet, indirectPath);
249
+ addNestedSelections(
250
+ parentType,
251
+ context,
252
+ info,
253
+ state,
254
+ selection.selectionSet,
255
+ indirectPath,
256
+ parentType.extensions?.pothosPrismaModel === type.extensions.pothosPrismaModel
257
+ ? parentType
258
+ : expectedType,
259
+ );
258
260
 
259
261
  continue;
260
262