@pothos/plugin-prisma 4.1.0 → 4.2.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 (171) hide show
  1. package/CHANGELOG.md +10 -4
  2. package/dts/connection-helpers.d.ts +2 -2
  3. package/dts/connection-helpers.d.ts.map +1 -1
  4. package/dts/global-types.d.ts +7 -7
  5. package/dts/global-types.d.ts.map +1 -1
  6. package/dts/index.d.ts +2 -2
  7. package/dts/index.d.ts.map +1 -1
  8. package/dts/interface-ref.d.ts +2 -2
  9. package/dts/interface-ref.d.ts.map +1 -1
  10. package/dts/model-loader.d.ts +4 -4
  11. package/dts/model-loader.d.ts.map +1 -1
  12. package/dts/node-ref.d.ts +1 -1
  13. package/dts/node-ref.d.ts.map +1 -1
  14. package/dts/object-ref.d.ts +1 -1
  15. package/dts/object-ref.d.ts.map +1 -1
  16. package/dts/prisma-field-builder.d.ts +4 -4
  17. package/dts/prisma-field-builder.d.ts.map +1 -1
  18. package/dts/types.d.ts +7 -7
  19. package/dts/types.d.ts.map +1 -1
  20. package/dts/util/cursors.d.ts +3 -3
  21. package/dts/util/cursors.d.ts.map +1 -1
  22. package/dts/util/datamodel.d.ts +3 -3
  23. package/dts/util/datamodel.d.ts.map +1 -1
  24. package/dts/util/deep-equal.d.ts.map +1 -1
  25. package/dts/util/description.d.ts +1 -1
  26. package/dts/util/description.d.ts.map +1 -1
  27. package/dts/util/get-client.d.ts +2 -2
  28. package/dts/util/get-client.d.ts.map +1 -1
  29. package/dts/util/loader-map.d.ts +2 -2
  30. package/dts/util/loader-map.d.ts.map +1 -1
  31. package/dts/util/map-query.d.ts +3 -3
  32. package/dts/util/map-query.d.ts.map +1 -1
  33. package/dts/util/relation-map.d.ts +1 -1
  34. package/dts/util/relation-map.d.ts.map +1 -1
  35. package/dts/util/selections.d.ts +2 -2
  36. package/dts/util/selections.d.ts.map +1 -1
  37. package/dts/util/usage.d.ts.map +1 -1
  38. package/esm/connection-helpers.d.ts +2 -2
  39. package/esm/connection-helpers.d.ts.map +1 -1
  40. package/esm/field-builder.js +6 -6
  41. package/esm/field-builder.js.map +1 -1
  42. package/esm/generator.js +5 -5
  43. package/esm/generator.js.map +1 -1
  44. package/esm/global-types.d.ts +7 -7
  45. package/esm/global-types.d.ts.map +1 -1
  46. package/esm/global-types.js +1 -1
  47. package/esm/global-types.js.map +1 -1
  48. package/esm/index.d.ts +2 -2
  49. package/esm/index.d.ts.map +1 -1
  50. package/esm/index.js +4 -4
  51. package/esm/index.js.map +1 -1
  52. package/esm/interface-ref.d.ts +2 -2
  53. package/esm/interface-ref.d.ts.map +1 -1
  54. package/esm/interface-ref.js.map +1 -1
  55. package/esm/model-loader.d.ts +4 -4
  56. package/esm/model-loader.d.ts.map +1 -1
  57. package/esm/model-loader.js +13 -15
  58. package/esm/model-loader.js.map +1 -1
  59. package/esm/node-ref.d.ts +1 -1
  60. package/esm/node-ref.d.ts.map +1 -1
  61. package/esm/object-ref.d.ts +1 -1
  62. package/esm/object-ref.d.ts.map +1 -1
  63. package/esm/object-ref.js +4 -2
  64. package/esm/object-ref.js.map +1 -1
  65. package/esm/prisma-field-builder.d.ts +4 -4
  66. package/esm/prisma-field-builder.d.ts.map +1 -1
  67. package/esm/prisma-field-builder.js +7 -8
  68. package/esm/prisma-field-builder.js.map +1 -1
  69. package/esm/schema-builder.js +1 -1
  70. package/esm/schema-builder.js.map +1 -1
  71. package/esm/types.d.ts +7 -7
  72. package/esm/types.d.ts.map +1 -1
  73. package/esm/types.js.map +1 -1
  74. package/esm/util/cursors.d.ts +3 -3
  75. package/esm/util/cursors.d.ts.map +1 -1
  76. package/esm/util/cursors.js +2 -2
  77. package/esm/util/cursors.js.map +1 -1
  78. package/esm/util/datamodel.d.ts +3 -3
  79. package/esm/util/datamodel.d.ts.map +1 -1
  80. package/esm/util/datamodel.js.map +1 -1
  81. package/esm/util/deep-equal.d.ts.map +1 -1
  82. package/esm/util/deep-equal.js +1 -1
  83. package/esm/util/deep-equal.js.map +1 -1
  84. package/esm/util/description.d.ts +1 -1
  85. package/esm/util/description.d.ts.map +1 -1
  86. package/esm/util/description.js +1 -1
  87. package/esm/util/description.js.map +1 -1
  88. package/esm/util/get-client.d.ts +2 -2
  89. package/esm/util/get-client.d.ts.map +1 -1
  90. package/esm/util/get-client.js +1 -1
  91. package/esm/util/get-client.js.map +1 -1
  92. package/esm/util/loader-map.d.ts +2 -2
  93. package/esm/util/loader-map.d.ts.map +1 -1
  94. package/esm/util/loader-map.js +4 -5
  95. package/esm/util/loader-map.js.map +1 -1
  96. package/esm/util/map-query.d.ts +3 -3
  97. package/esm/util/map-query.d.ts.map +1 -1
  98. package/esm/util/map-query.js +2 -3
  99. package/esm/util/map-query.js.map +1 -1
  100. package/esm/util/relation-map.d.ts +1 -1
  101. package/esm/util/relation-map.d.ts.map +1 -1
  102. package/esm/util/relation-map.js +12 -12
  103. package/esm/util/relation-map.js.map +1 -1
  104. package/esm/util/selections.d.ts +2 -2
  105. package/esm/util/selections.d.ts.map +1 -1
  106. package/esm/util/selections.js +9 -9
  107. package/esm/util/selections.js.map +1 -1
  108. package/esm/util/usage.d.ts.map +1 -1
  109. package/esm/util/usage.js +0 -1
  110. package/esm/util/usage.js.map +1 -1
  111. package/generated.d.ts +1 -1
  112. package/lib/field-builder.js +7 -5
  113. package/lib/field-builder.js.map +1 -1
  114. package/lib/generator.js +4 -4
  115. package/lib/generator.js.map +1 -1
  116. package/lib/global-types.js +1 -1
  117. package/lib/global-types.js.map +1 -1
  118. package/lib/index.js +4 -4
  119. package/lib/index.js.map +1 -1
  120. package/lib/interface-ref.js.map +1 -1
  121. package/lib/model-loader.js +12 -14
  122. package/lib/model-loader.js.map +1 -1
  123. package/lib/object-ref.js +3 -1
  124. package/lib/object-ref.js.map +1 -1
  125. package/lib/prisma-field-builder.js +6 -7
  126. package/lib/prisma-field-builder.js.map +1 -1
  127. package/lib/schema-builder.js +1 -1
  128. package/lib/schema-builder.js.map +1 -1
  129. package/lib/types.js.map +1 -1
  130. package/lib/util/cursors.js +2 -2
  131. package/lib/util/cursors.js.map +1 -1
  132. package/lib/util/datamodel.js.map +1 -1
  133. package/lib/util/deep-equal.js +1 -1
  134. package/lib/util/deep-equal.js.map +1 -1
  135. package/lib/util/description.js +1 -1
  136. package/lib/util/description.js.map +1 -1
  137. package/lib/util/get-client.js +1 -1
  138. package/lib/util/get-client.js.map +1 -1
  139. package/lib/util/loader-map.js +4 -5
  140. package/lib/util/loader-map.js.map +1 -1
  141. package/lib/util/map-query.js +2 -3
  142. package/lib/util/map-query.js.map +1 -1
  143. package/lib/util/relation-map.js +12 -12
  144. package/lib/util/relation-map.js.map +1 -1
  145. package/lib/util/selections.js +9 -9
  146. package/lib/util/selections.js.map +1 -1
  147. package/lib/util/usage.js +0 -1
  148. package/lib/util/usage.js.map +1 -1
  149. package/package.json +12 -12
  150. package/src/connection-helpers.ts +2 -2
  151. package/src/field-builder.ts +21 -13
  152. package/src/generator.ts +5 -8
  153. package/src/global-types.ts +31 -26
  154. package/src/index.ts +12 -11
  155. package/src/interface-ref.ts +2 -2
  156. package/src/model-loader.ts +17 -19
  157. package/src/node-ref.ts +1 -1
  158. package/src/object-ref.ts +5 -3
  159. package/src/prisma-field-builder.ts +54 -49
  160. package/src/schema-builder.ts +8 -8
  161. package/src/types.ts +58 -59
  162. package/src/util/cursors.ts +7 -8
  163. package/src/util/datamodel.ts +3 -3
  164. package/src/util/deep-equal.ts +0 -1
  165. package/src/util/description.ts +1 -2
  166. package/src/util/get-client.ts +2 -3
  167. package/src/util/loader-map.ts +6 -8
  168. package/src/util/map-query.ts +16 -19
  169. package/src/util/relation-map.ts +13 -13
  170. package/src/util/selections.ts +10 -12
  171. package/src/util/usage.ts +0 -2
package/src/types.ts CHANGED
@@ -1,33 +1,35 @@
1
- import { FieldNode, GraphQLResolveInfo } from 'graphql';
2
1
  import {
3
- ArgumentRef,
4
- FieldKind,
5
- FieldMap,
6
- FieldNullability,
7
- FieldOptionsFromKind,
8
- InferredFieldOptionsByKind,
9
- InferredFieldOptionKeys,
10
- InputFieldMap,
11
- InputFieldsFromShape,
12
- InputShapeFromFields,
13
- InterfaceParam,
14
- ListResolveValue,
15
- MaybePromise,
16
- Normalize,
17
- ObjectRef,
18
- OutputShape,
19
- OutputType,
20
- SchemaTypes,
21
- ShapeFromTypeParam,
22
- ShapeWithNullability,
2
+ type ArgumentRef,
3
+ type FieldKind,
4
+ type FieldMap,
5
+ type FieldNullability,
6
+ type FieldOptionsFromKind,
7
+ type InferredFieldOptionKeys,
8
+ type InferredFieldOptionsByKind,
9
+ type InputFieldMap,
10
+ type InputFieldsFromShape,
11
+ type InputShapeFromFields,
12
+ type InterfaceParam,
13
+ type ListResolveValue,
14
+ type MaybePromise,
15
+ type Normalize,
16
+ type ObjectRef,
17
+ type OutputShape,
18
+ type OutputType,
19
+ type SchemaTypes,
20
+ type ShapeFromTypeParam,
21
+ type ShapeWithNullability,
22
+ type TypeParam,
23
23
  typeBrandKey,
24
- TypeParam,
25
24
  } from '@pothos/core';
26
- import { PrismaInterfaceRef, PrismaRef } from './interface-ref';
25
+ import type { FieldNode, GraphQLResolveInfo } from 'graphql';
26
+ import type { PrismaInterfaceRef, PrismaRef } from './interface-ref';
27
27
  import type { PrismaObjectFieldBuilder } from './prisma-field-builder';
28
28
 
29
29
  export interface PrismaDelegate {
30
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
30
31
  findUniqueOrThrow?: (...args: any[]) => Promise<unknown>;
32
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
31
33
  findUnique: (...args: any[]) => Promise<unknown>;
32
34
  }
33
35
 
@@ -84,6 +86,7 @@ export type PrismaObjectFieldOptions<
84
86
  ShapeFromSelection<
85
87
  Types,
86
88
  ExtractModel<Types, ParentShape>,
89
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
87
90
  { select: Select extends (...args: any[]) => infer S ? S : Select }
88
91
  >,
89
92
  > = PothosSchemaTypes.ObjectFieldOptions<Types, Shape, Type, Nullable, Args, ResolveReturnShape> &
@@ -499,10 +502,11 @@ export type RelationCountOptions<
499
502
  export type PrismaFieldOptions<
500
503
  Types extends SchemaTypes,
501
504
  ParentShape,
502
- Type extends
505
+ Type extends // biome-ignore lint/suspicious/noExplicitAny: <explanation>
503
506
  | PrismaRef<any, PrismaModelTypes>
504
507
  | keyof Types['PrismaTypes']
505
508
  | [keyof Types['PrismaTypes']]
509
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
506
510
  | [PrismaRef<any, PrismaModelTypes>],
507
511
  Model extends PrismaModelTypes,
508
512
  Param extends TypeParam<Types>,
@@ -511,34 +515,26 @@ export type PrismaFieldOptions<
511
515
  ResolveShape,
512
516
  ResolveReturnShape,
513
517
  Kind extends FieldKind = FieldKind,
514
- > =
515
- FieldOptionsFromKind<
516
- Types,
517
- ParentShape,
518
- Param,
519
- Nullable,
520
- Args,
521
- Kind,
522
- ResolveShape,
523
- ResolveReturnShape
524
- > extends infer FieldOptions
525
- ? Omit<FieldOptions, InferredFieldOptionKeys | 'type'> & {
526
- type: Type;
527
- resolve: FieldOptions extends {
528
- resolve?: (parent: infer Parent, ...args: any[]) => unknown;
529
- }
530
- ? PrismaFieldResolver<Types, Model, Parent, Param, Args, Nullable, ResolveReturnShape>
531
- : PrismaFieldResolver<
532
- Types,
533
- Model,
534
- ParentShape,
535
- Param,
536
- Args,
537
- Nullable,
538
- ResolveReturnShape
539
- >;
518
+ > = FieldOptionsFromKind<
519
+ Types,
520
+ ParentShape,
521
+ Param,
522
+ Nullable,
523
+ Args,
524
+ Kind,
525
+ ResolveShape,
526
+ ResolveReturnShape
527
+ > extends infer FieldOptions
528
+ ? Omit<FieldOptions, InferredFieldOptionKeys | 'type'> & {
529
+ type: Type;
530
+ resolve: FieldOptions extends {
531
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
532
+ resolve?: (parent: infer Parent, ...args: any[]) => unknown;
540
533
  }
541
- : never;
534
+ ? PrismaFieldResolver<Types, Model, Parent, Param, Args, Nullable, ResolveReturnShape>
535
+ : PrismaFieldResolver<Types, Model, ParentShape, Param, Args, Nullable, ResolveReturnShape>;
536
+ }
537
+ : never;
542
538
 
543
539
  export type PrismaFieldWithInputOptions<
544
540
  Types extends SchemaTypes,
@@ -546,10 +542,11 @@ export type PrismaFieldWithInputOptions<
546
542
  Kind extends FieldKind,
547
543
  Args extends InputFieldMap,
548
544
  Fields extends InputFieldMap,
549
- Type extends
545
+ Type extends // biome-ignore lint/suspicious/noExplicitAny: <explanation>
550
546
  | PrismaRef<any, PrismaModelTypes>
551
547
  | keyof Types['PrismaTypes']
552
548
  | [keyof Types['PrismaTypes']]
549
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
553
550
  | [PrismaRef<any, PrismaModelTypes>],
554
551
  Model extends PrismaModelTypes,
555
552
  Param extends TypeParam<Types>,
@@ -617,8 +614,9 @@ export type PrismaFieldResolver<
617
614
  export type PrismaConnectionFieldOptions<
618
615
  Types extends SchemaTypes,
619
616
  ParentShape,
620
- Type extends
617
+ Type extends // biome-ignore lint/suspicious/noExplicitAny: <explanation>
621
618
  | PrismaInterfaceRef<any, PrismaModelTypes>
619
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
622
620
  | PrismaRef<any, PrismaModelTypes>
623
621
  | keyof Types['PrismaTypes'],
624
622
  Model extends PrismaModelTypes,
@@ -627,7 +625,6 @@ export type PrismaConnectionFieldOptions<
627
625
  Args extends InputFieldMap,
628
626
  ResolveReturnShape,
629
627
  Kind extends FieldKind,
630
- // eslint-disable-next-line @typescript-eslint/sort-type-constituents
631
628
  > = Omit<
632
629
  FieldOptionsFromKind<
633
630
  Types,
@@ -693,7 +690,6 @@ export type RelatedConnectionOptions<
693
690
  Field extends Model['ListRelations'],
694
691
  Nullable extends boolean,
695
692
  Args extends InputFieldMap,
696
- // eslint-disable-next-line @typescript-eslint/sort-type-constituents
697
693
  > = Omit<
698
694
  PothosSchemaTypes.ObjectFieldOptions<
699
695
  Types,
@@ -758,7 +754,7 @@ export type IncludeMap = Record<string, SelectionMap | boolean>;
758
754
  export interface SelectionMap {
759
755
  select?: Record<string, SelectionMap | boolean>;
760
756
  include?: Record<string, SelectionMap | boolean>;
761
- where?: {};
757
+ where?: object;
762
758
  }
763
759
 
764
760
  export type FieldSelection =
@@ -849,7 +845,8 @@ type InferModelShape<Model> = Simplify<
849
845
  // Infer relations for a given model
850
846
  type InferRelations<Model> = {
851
847
  [K in keyof Model]: {
852
- Shape: Model[K] extends Array<any> ? InferModelShape<Model[K][0]>[] : InferModelShape<Model[K]>;
848
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
849
+ Shape: Model[K] extends any[] ? InferModelShape<Model[K][0]>[] : InferModelShape<Model[K]>;
853
850
  Name: InferField<InferItemOfArray<Model[K]>, 'name'>;
854
851
  Nullable: IsNullable<Model[K]>;
855
852
  };
@@ -857,7 +854,8 @@ type InferRelations<Model> = {
857
854
 
858
855
  // Create a list of keys that represent array relations
859
856
  type InferRelationList<Model> = {
860
- [K in keyof Model as Model[K] extends Array<any> ? K : never]: K;
857
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
858
+ [K in keyof Model as Model[K] extends any[] ? K : never]: K;
861
859
  };
862
860
 
863
861
  // Make a type nullable if IsNullable is true
@@ -868,7 +866,8 @@ type InferItemOfArray<T> = T extends Array<infer U> ? U : T;
868
866
 
869
867
  // Infers the composites of a given model
870
868
  type InferComposites<Model> = {
871
- [K in keyof Model]: Model[K] extends Array<any>
869
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
870
+ [K in keyof Model]: Model[K] extends any[]
872
871
  ? Simplify<
873
872
  InferField<Model[K][0], 'scalars'> & InferComposites<InferField<Model[K][0], 'composites'>>
874
873
  >[]
@@ -1,13 +1,12 @@
1
- /* eslint-disable no-nested-ternary */
2
1
  import {
2
+ type MaybePromise,
3
+ PothosValidationError,
4
+ type SchemaTypes,
3
5
  decodeBase64,
4
6
  encodeBase64,
5
- MaybePromise,
6
- PothosValidationError,
7
- SchemaTypes,
8
7
  } from '@pothos/core';
9
8
  import { getModel } from './datamodel';
10
- import { DMMFField } from './get-client';
9
+ import type { DMMFField } from './get-client';
11
10
  import { extendWithUsage } from './usage';
12
11
 
13
12
  const DEFAULT_MAX_SIZE = 100;
@@ -303,7 +302,7 @@ export function wrapConnectionResult<T extends {}>(
303
302
  },
304
303
  };
305
304
 
306
- const edges = nodes.map((value, index) =>
305
+ const edges = nodes.map((value) =>
307
306
  value == null
308
307
  ? null
309
308
  : resolveNode
@@ -331,8 +330,8 @@ export async function resolvePrismaCursorConnection<T extends {}>(
331
330
  options: ResolvePrismaCursorConnectionOptions,
332
331
  cursor: (node: T) => string,
333
332
  resolve: (query: {
334
- include?: {};
335
- cursor?: {};
333
+ include?: object;
334
+ cursor?: object;
336
335
  take: number;
337
336
  skip: number;
338
337
  }) => MaybePromise<readonly T[]>,
@@ -1,7 +1,7 @@
1
- import { ObjectRef, PothosSchemaError, SchemaTypes } from '@pothos/core';
2
- import { PrismaInterfaceRef, PrismaRef } from '../interface-ref';
1
+ import { type ObjectRef, PothosSchemaError, type SchemaTypes } from '@pothos/core';
2
+ import { PrismaInterfaceRef, type PrismaRef } from '../interface-ref';
3
3
  import { PrismaObjectRef } from '../object-ref';
4
- import { PrismaClient, PrismaDelegate, PrismaModelTypes } from '../types';
4
+ import type { PrismaClient, PrismaDelegate, PrismaModelTypes } from '../types';
5
5
  import { getDMMF } from './get-client';
6
6
 
7
7
  export const refMap = new WeakMap<object, Map<string, PrismaRef<never, PrismaModelTypes>>>();
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-continue */
2
1
  export function deepEqual(left: unknown, right: unknown, ignore?: Set<string>) {
3
2
  if (left === right) {
4
3
  return true;
@@ -1,5 +1,4 @@
1
- /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
2
- import { SchemaTypes } from '@pothos/core';
1
+ import type { SchemaTypes } from '@pothos/core';
3
2
  import { getFieldData, getModel } from './datamodel';
4
3
 
5
4
  export function getFieldDescription<Types extends SchemaTypes>(
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-underscore-dangle */
2
- import { createContextCache, SchemaTypes } from '@pothos/core';
3
- import { PrismaClient } from '../types';
1
+ import { type SchemaTypes, createContextCache } from '@pothos/core';
2
+ import type { PrismaClient } from '../types';
4
3
 
5
4
  export interface DMMFField {
6
5
  type: string;
@@ -1,8 +1,8 @@
1
- import { GraphQLResolveInfo } from 'graphql';
2
1
  import { createContextCache } from '@pothos/core';
3
- import { LoaderMappings } from '../types';
2
+ import type { GraphQLResolveInfo } from 'graphql';
3
+ import type { LoaderMappings } from '../types';
4
4
 
5
- const cache = createContextCache((ctx) => new Map<string, LoaderMappings>());
5
+ const cache = createContextCache(() => new Map<string, LoaderMappings>());
6
6
 
7
7
  export function cacheKey(type: string, path: GraphQLResolveInfo['path'], subPath: string[] = []) {
8
8
  let key = '';
@@ -23,15 +23,13 @@ export function cacheKey(type: string, path: GraphQLResolveInfo['path'], subPath
23
23
  }
24
24
 
25
25
  export function setLoaderMappings(ctx: object, info: GraphQLResolveInfo, value: LoaderMappings) {
26
- Object.keys(value).forEach((field) => {
27
- const map = cache(ctx);
28
-
29
- const mapping = value[field];
26
+ const map = cache(ctx);
27
+ for (const [field, mapping] of Object.entries(value)) {
30
28
  const subPath = [...mapping.indirectPath, field];
31
29
  const key = cacheKey(mapping.type, info.path, subPath);
32
30
 
33
31
  map.set(key, mapping.mappings);
34
- });
32
+ }
35
33
  }
36
34
 
37
35
  export function getLoaderMapping(ctx: object, path: GraphQLResolveInfo['path'], type: string) {
@@ -1,25 +1,23 @@
1
- /* eslint-disable no-param-reassign */
2
- /* eslint-disable no-continue */
1
+ import { PothosValidationError, getMappedArgumentValues } from '@pothos/core';
3
2
  import {
4
- FieldNode,
5
- FragmentDefinitionNode,
6
- getDirectiveValues,
7
- getNamedType,
8
- GraphQLField,
3
+ type FieldNode,
4
+ type FragmentDefinitionNode,
5
+ type GraphQLField,
9
6
  GraphQLIncludeDirective,
10
- GraphQLInterfaceType,
11
- GraphQLNamedType,
12
- GraphQLObjectType,
13
- GraphQLResolveInfo,
7
+ type GraphQLInterfaceType,
8
+ type GraphQLNamedType,
9
+ type GraphQLObjectType,
10
+ type GraphQLResolveInfo,
14
11
  GraphQLSkipDirective,
15
- InlineFragmentNode,
12
+ type InlineFragmentNode,
13
+ Kind,
14
+ type SelectionSetNode,
15
+ getDirectiveValues,
16
+ getNamedType,
16
17
  isInterfaceType,
17
18
  isObjectType,
18
- Kind,
19
- SelectionSetNode,
20
19
  } from 'graphql';
21
- import { getMappedArgumentValues, PothosValidationError } from '@pothos/core';
22
- import {
20
+ import type {
23
21
  FieldSelection,
24
22
  IncludeMap,
25
23
  IndirectInclude,
@@ -27,12 +25,12 @@ import {
27
25
  SelectionMap,
28
26
  } from '../types';
29
27
  import { setLoaderMappings } from './loader-map';
30
- import { FieldMap } from './relation-map';
28
+ import type { FieldMap } from './relation-map';
31
29
  import {
30
+ type SelectionState,
32
31
  createState,
33
32
  mergeSelection,
34
33
  selectionCompatible,
35
- SelectionState,
36
34
  selectionToQuery,
37
35
  } from './selections';
38
36
  import { wrapWithUsageCheck } from './usage';
@@ -355,7 +353,6 @@ function addFieldSelection(
355
353
 
356
354
  addTypeSelectionsForField(returnType, context, info, fieldState, selection, []);
357
355
 
358
- // eslint-disable-next-line prefer-destructuring
359
356
  mappings = fieldState.mappings;
360
357
 
361
358
  return selectionToQuery(fieldState);
@@ -1,5 +1,5 @@
1
1
  import { createContextCache } from '@pothos/core';
2
- import { DMMF, RuntimeDataModel } from './get-client';
2
+ import type { DMMF, RuntimeDataModel } from './get-client';
3
3
 
4
4
  export interface FieldMap {
5
5
  model: string;
@@ -16,33 +16,33 @@ export function createRelationMap({ models }: DMMF['datamodel'] | RuntimeDataMod
16
16
  const relationMap: RelationMap = new Map();
17
17
 
18
18
  if (Array.isArray(models)) {
19
- models.forEach((model) => {
19
+ for (const model of models) {
20
20
  relationMap.set(model.name, { model: model.name, relations: new Map() });
21
- });
21
+ }
22
22
 
23
- models.forEach((model) => {
23
+ for (const model of models) {
24
24
  const map = relationMap.get(model.name)!.relations;
25
25
 
26
- model.fields.forEach((field) => {
26
+ for (const field of model.fields) {
27
27
  if (field.kind === 'object' && relationMap.has(field.type)) {
28
28
  map.set(field.name, relationMap.get(field.type)!);
29
29
  }
30
- });
31
- });
30
+ }
31
+ }
32
32
  } else {
33
- Object.keys(models).forEach((name) => {
33
+ for (const name of Object.keys(models)) {
34
34
  relationMap.set(name, { model: name, relations: new Map() });
35
- });
35
+ }
36
36
 
37
- Object.entries(models).forEach(([name, model]) => {
37
+ for (const [name, model] of Object.entries(models)) {
38
38
  const map = relationMap.get(name)!.relations;
39
39
 
40
- model.fields.forEach((field) => {
40
+ for (const field of model.fields) {
41
41
  if (field.kind === 'object' && relationMap.has(field.type)) {
42
42
  map.set(field.name, relationMap.get(field.type)!);
43
43
  }
44
- });
45
- });
44
+ }
45
+ }
46
46
  }
47
47
 
48
48
  return relationMap;
@@ -1,8 +1,6 @@
1
- /* eslint-disable no-param-reassign */
2
- /* eslint-disable no-underscore-dangle */
3
- import { LoaderMappings, SelectionMap } from '../types';
1
+ import type { LoaderMappings, SelectionMap } from '../types';
4
2
  import { deepEqual } from './deep-equal';
5
- import { FieldMap } from './relation-map';
3
+ import type { FieldMap } from './relation-map';
6
4
 
7
5
  export type SelectionMode = 'include' | 'select';
8
6
 
@@ -114,15 +112,15 @@ export function mergeSelection(state: SelectionState, { select, include, ...quer
114
112
  }
115
113
 
116
114
  if (include) {
117
- Object.keys(include).forEach((key) => {
115
+ for (const key of Object.keys(include)) {
118
116
  merge(key, include[key]);
119
- });
117
+ }
120
118
  }
121
119
 
122
120
  if (select) {
123
- Object.keys(select).forEach((key) => {
121
+ for (const key of Object.keys(select)) {
124
122
  merge(key, select[key]);
125
- });
123
+ }
126
124
  }
127
125
 
128
126
  if (Object.keys(query).length > 0) {
@@ -136,9 +134,9 @@ export function mergeSelection(state: SelectionState, { select, include, ...quer
136
134
 
137
135
  if (key === '_count') {
138
136
  const counts = (value as { select?: Record<string, boolean> }).select ?? {};
139
- Object.keys(counts).forEach((count) => {
137
+ for (const count of Object.keys(counts)) {
140
138
  state.counts.set(count, counts[count]);
141
- });
139
+ }
142
140
 
143
141
  return;
144
142
  }
@@ -184,10 +182,10 @@ export function selectionToQuery(state: SelectionState): SelectionMap {
184
182
  }
185
183
 
186
184
  if (state.mode === 'select') {
187
- state.fields.forEach((field) => {
185
+ for (const field of state.fields) {
188
186
  hasSelection = true;
189
187
  nestedIncludes[field] = true;
190
- });
188
+ }
191
189
 
192
190
  return {
193
191
  ...(state.query as SelectionMap),
package/src/util/usage.ts CHANGED
@@ -20,7 +20,6 @@ export function wrapWithUsageCheck<T extends Object>(obj: T): T {
20
20
  Object.defineProperty(result, key, {
21
21
  enumerable: true,
22
22
  configurable: true,
23
- // eslint-disable-next-line @typescript-eslint/no-loop-func
24
23
  get() {
25
24
  used = true;
26
25
  return obj[key as keyof T];
@@ -47,7 +46,6 @@ export function extendWithUsage<T extends object, U extends object>(
47
46
 
48
47
  for (const key of [usageSymbol, ...Object.keys(original)]) {
49
48
  if (key in result) {
50
- // eslint-disable-next-line no-continue
51
49
  continue;
52
50
  }
53
51