@pothos/plugin-prisma 4.0.5 → 4.1.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 +7 -0
- package/dts/global-types.d.ts +2 -2
- package/dts/global-types.d.ts.map +1 -1
- package/dts/prisma-field-builder.d.ts +1 -1
- package/dts/prisma-field-builder.d.ts.map +1 -1
- package/dts/types.d.ts +1 -1
- package/dts/types.d.ts.map +1 -1
- package/dts/util/map-query.d.ts +10 -5
- package/dts/util/map-query.d.ts.map +1 -1
- package/esm/field-builder.js.map +1 -1
- package/esm/global-types.d.ts +2 -2
- package/esm/global-types.d.ts.map +1 -1
- package/esm/prisma-field-builder.d.ts +1 -1
- package/esm/prisma-field-builder.d.ts.map +1 -1
- package/esm/prisma-field-builder.js.map +1 -1
- package/esm/types.d.ts +1 -1
- package/esm/types.d.ts.map +1 -1
- package/esm/util/map-query.d.ts +10 -5
- package/esm/util/map-query.d.ts.map +1 -1
- package/esm/util/map-query.js +18 -16
- package/esm/util/map-query.js.map +1 -1
- package/lib/field-builder.js.map +1 -1
- package/lib/prisma-field-builder.js.map +1 -1
- package/lib/util/map-query.js +18 -16
- package/lib/util/map-query.js.map +1 -1
- package/package.json +2 -2
- package/src/field-builder.ts +9 -6
- package/src/global-types.ts +2 -2
- package/src/prisma-field-builder.ts +0 -4
- package/src/types.ts +1 -1
- package/src/util/map-query.ts +33 -27
package/src/global-types.ts
CHANGED
|
@@ -353,7 +353,7 @@ declare global {
|
|
|
353
353
|
>
|
|
354
354
|
: '@pothos/plugin-relay is required to use this method';
|
|
355
355
|
|
|
356
|
-
prismaFieldWithInput: '
|
|
356
|
+
prismaFieldWithInput: 'withInput' extends PluginName
|
|
357
357
|
? <
|
|
358
358
|
Fields extends InputFieldMap,
|
|
359
359
|
TypeParam extends
|
|
@@ -399,7 +399,7 @@ declare global {
|
|
|
399
399
|
: ArgRequired
|
|
400
400
|
>,
|
|
401
401
|
) => FieldRef<Types, ShapeFromTypeParam<Types, Type, Nullable>>
|
|
402
|
-
: '@pothos/plugin-
|
|
402
|
+
: '@pothos/plugin-with-input is required to use this method';
|
|
403
403
|
}
|
|
404
404
|
|
|
405
405
|
export interface ConnectionFieldOptions<
|
|
@@ -137,10 +137,6 @@ export class PrismaObjectFieldBuilder<
|
|
|
137
137
|
>
|
|
138
138
|
>
|
|
139
139
|
>
|
|
140
|
-
| ObjectRef<
|
|
141
|
-
Types,
|
|
142
|
-
ShapeFromConnection<PothosSchemaTypes.ConnectionShapeHelper<Types, Shape, false>>
|
|
143
|
-
>
|
|
144
140
|
| PothosSchemaTypes.ConnectionObjectOptions<
|
|
145
141
|
Types,
|
|
146
142
|
ObjectRef<
|
package/src/types.ts
CHANGED
|
@@ -618,7 +618,7 @@ export type PrismaConnectionFieldOptions<
|
|
|
618
618
|
Types extends SchemaTypes,
|
|
619
619
|
ParentShape,
|
|
620
620
|
Type extends
|
|
621
|
-
| PrismaInterfaceRef<
|
|
621
|
+
| PrismaInterfaceRef<any, PrismaModelTypes>
|
|
622
622
|
| PrismaRef<any, PrismaModelTypes>
|
|
623
623
|
| keyof Types['PrismaTypes'],
|
|
624
624
|
Model extends PrismaModelTypes,
|
package/src/util/map-query.ts
CHANGED
|
@@ -49,36 +49,32 @@ function addTypeSelectionsForField(
|
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
const {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
pothosPrismaInclude?: IncludeMap;
|
|
60
|
-
pothosPrismaSelect?: IncludeMap;
|
|
61
|
-
pothosPrismaIndirectInclude?: IndirectInclude;
|
|
62
|
-
};
|
|
52
|
+
const { pothosPrismaInclude, pothosPrismaSelect, pothosIndirectInclude, pothosPrismaModel } =
|
|
53
|
+
(type.extensions ?? {}) as {
|
|
54
|
+
pothosPrismaModel?: string;
|
|
55
|
+
pothosPrismaInclude?: IncludeMap;
|
|
56
|
+
pothosPrismaSelect?: IncludeMap;
|
|
57
|
+
pothosIndirectInclude?: IndirectInclude;
|
|
58
|
+
};
|
|
63
59
|
|
|
64
60
|
if (
|
|
65
|
-
(!!
|
|
66
|
-
(!!
|
|
61
|
+
(!!pothosIndirectInclude?.path && pothosIndirectInclude.path.length > 0) ||
|
|
62
|
+
(!!pothosIndirectInclude?.paths && pothosIndirectInclude.paths.length === 0)
|
|
67
63
|
) {
|
|
68
64
|
resolveIndirectIncludePaths(
|
|
69
65
|
type,
|
|
70
66
|
info,
|
|
71
67
|
selection,
|
|
72
68
|
[],
|
|
73
|
-
|
|
69
|
+
pothosIndirectInclude.paths ?? [pothosIndirectInclude.path!],
|
|
74
70
|
indirectPath,
|
|
75
71
|
(resolvedType, field, path) => {
|
|
76
72
|
addTypeSelectionsForField(resolvedType, context, info, state, field, path);
|
|
77
73
|
},
|
|
78
74
|
);
|
|
79
|
-
} else if (
|
|
75
|
+
} else if (pothosIndirectInclude) {
|
|
80
76
|
addTypeSelectionsForField(
|
|
81
|
-
info.schema.getType(
|
|
77
|
+
info.schema.getType(pothosIndirectInclude.getType())!,
|
|
82
78
|
context,
|
|
83
79
|
info,
|
|
84
80
|
state,
|
|
@@ -335,7 +331,7 @@ function addFieldSelection(
|
|
|
335
331
|
returnType,
|
|
336
332
|
info,
|
|
337
333
|
selection,
|
|
338
|
-
(returnType.extensions?.
|
|
334
|
+
(returnType.extensions?.pothosIndirectInclude as { path: [] })?.path ?? [],
|
|
339
335
|
normalizedIndirectInclude?.paths ??
|
|
340
336
|
(normalizedIndirectInclude?.path ? [normalizedIndirectInclude.path] : []),
|
|
341
337
|
[],
|
|
@@ -403,11 +399,15 @@ function addFieldSelection(
|
|
|
403
399
|
}
|
|
404
400
|
}
|
|
405
401
|
|
|
406
|
-
export function queryFromInfo<
|
|
402
|
+
export function queryFromInfo<
|
|
403
|
+
Select extends SelectionMap['select'] | undefined = undefined,
|
|
404
|
+
Include extends SelectionMap['select'] | undefined = undefined,
|
|
405
|
+
>({
|
|
407
406
|
context,
|
|
408
407
|
info,
|
|
409
408
|
typeName,
|
|
410
409
|
select,
|
|
410
|
+
include,
|
|
411
411
|
path = [],
|
|
412
412
|
paths = [],
|
|
413
413
|
withUsageCheck = false,
|
|
@@ -415,27 +415,33 @@ export function queryFromInfo<T extends SelectionMap['select'] | undefined = und
|
|
|
415
415
|
context: object;
|
|
416
416
|
info: GraphQLResolveInfo;
|
|
417
417
|
typeName?: string;
|
|
418
|
-
select?: T;
|
|
419
418
|
path?: string[];
|
|
420
419
|
paths?: string[][];
|
|
421
420
|
withUsageCheck?: boolean;
|
|
422
|
-
}
|
|
421
|
+
} & (
|
|
422
|
+
| { include?: Include; select?: never }
|
|
423
|
+
| { select?: Select; include?: never }
|
|
424
|
+
)): undefined extends Include
|
|
425
|
+
? {
|
|
426
|
+
select: Select;
|
|
427
|
+
}
|
|
428
|
+
: { include: Include } {
|
|
423
429
|
const returnType = getNamedType(info.returnType);
|
|
424
430
|
const type = typeName ? info.schema.getTypeMap()[typeName] : returnType;
|
|
425
431
|
|
|
426
432
|
let state: SelectionState | undefined;
|
|
427
|
-
const initialSelection = select ? { select } : undefined;
|
|
433
|
+
const initialSelection = select ? { select } : include ? { include } : undefined;
|
|
428
434
|
|
|
429
435
|
if (path.length > 0 || paths.length > 0) {
|
|
430
|
-
const {
|
|
431
|
-
|
|
436
|
+
const { pothosIndirectInclude } = (returnType.extensions ?? {}) as {
|
|
437
|
+
pothosIndirectInclude?: IndirectInclude;
|
|
432
438
|
};
|
|
433
439
|
|
|
434
440
|
resolveIndirectInclude(
|
|
435
441
|
returnType,
|
|
436
442
|
info,
|
|
437
443
|
info.fieldNodes[0],
|
|
438
|
-
|
|
444
|
+
pothosIndirectInclude?.path ?? [],
|
|
439
445
|
[],
|
|
440
446
|
(indirectType, indirectField, subPath) => {
|
|
441
447
|
resolveIndirectIncludePaths(
|
|
@@ -479,7 +485,7 @@ export function queryFromInfo<T extends SelectionMap['select'] | undefined = und
|
|
|
479
485
|
|
|
480
486
|
setLoaderMappings(context, info, state.mappings);
|
|
481
487
|
|
|
482
|
-
const query = selectionToQuery(state) as { select:
|
|
488
|
+
const query = selectionToQuery(state) as { select: Select; include: Include };
|
|
483
489
|
|
|
484
490
|
return withUsageCheck ? wrapWithUsageCheck(query) : query;
|
|
485
491
|
}
|
|
@@ -530,9 +536,9 @@ function createStateForType(
|
|
|
530
536
|
export function getIndirectType(type: GraphQLNamedType, info: GraphQLResolveInfo) {
|
|
531
537
|
let targetType = type;
|
|
532
538
|
|
|
533
|
-
while (targetType.extensions?.
|
|
539
|
+
while (targetType.extensions?.pothosIndirectInclude) {
|
|
534
540
|
targetType = info.schema.getType(
|
|
535
|
-
(targetType.extensions?.
|
|
541
|
+
(targetType.extensions?.pothosIndirectInclude as IndirectInclude).getType(),
|
|
536
542
|
)!;
|
|
537
543
|
}
|
|
538
544
|
|