@pothos/plugin-drizzle 0.0.1 → 0.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.
Files changed (150) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/drizzle/meta/_journal.json +1 -1
  3. package/dts/drizzle-field-builder.d.ts +9 -9
  4. package/dts/drizzle-field-builder.d.ts.map +1 -1
  5. package/dts/global-types.d.ts +7 -7
  6. package/dts/global-types.d.ts.map +1 -1
  7. package/dts/index.d.ts +2 -2
  8. package/dts/index.d.ts.map +1 -1
  9. package/dts/interface-ref.d.ts +2 -2
  10. package/dts/interface-ref.d.ts.map +1 -1
  11. package/dts/model-loader.d.ts +5 -5
  12. package/dts/model-loader.d.ts.map +1 -1
  13. package/dts/node-ref.d.ts +1 -1
  14. package/dts/node-ref.d.ts.map +1 -1
  15. package/dts/object-ref.d.ts +1 -1
  16. package/dts/object-ref.d.ts.map +1 -1
  17. package/dts/types.d.ts +10 -9
  18. package/dts/types.d.ts.map +1 -1
  19. package/dts/utils/config.d.ts +2 -2
  20. package/dts/utils/config.d.ts.map +1 -1
  21. package/dts/utils/cursors.d.ts +7 -7
  22. package/dts/utils/cursors.d.ts.map +1 -1
  23. package/dts/utils/deep-equal.d.ts.map +1 -1
  24. package/dts/utils/drizzle-graphql.d.ts +1 -1
  25. package/dts/utils/drizzle-graphql.d.ts.map +1 -1
  26. package/dts/utils/loader-map.d.ts +1 -1
  27. package/dts/utils/loader-map.d.ts.map +1 -1
  28. package/dts/utils/map-query.d.ts +3 -3
  29. package/dts/utils/map-query.d.ts.map +1 -1
  30. package/dts/utils/refs.d.ts +2 -2
  31. package/dts/utils/refs.d.ts.map +1 -1
  32. package/dts/utils/selections.d.ts +3 -3
  33. package/dts/utils/selections.d.ts.map +1 -1
  34. package/dts/utils/usage.d.ts.map +1 -1
  35. package/esm/drizzle-field-builder.d.ts +9 -9
  36. package/esm/drizzle-field-builder.d.ts.map +1 -1
  37. package/esm/global-types.d.ts +7 -7
  38. package/esm/global-types.d.ts.map +1 -1
  39. package/esm/index.d.ts +2 -2
  40. package/esm/index.d.ts.map +1 -1
  41. package/esm/interface-ref.d.ts +2 -2
  42. package/esm/interface-ref.d.ts.map +1 -1
  43. package/esm/model-loader.d.ts +5 -5
  44. package/esm/model-loader.d.ts.map +1 -1
  45. package/esm/node-ref.d.ts +1 -1
  46. package/esm/node-ref.d.ts.map +1 -1
  47. package/esm/object-ref.d.ts +1 -1
  48. package/esm/object-ref.d.ts.map +1 -1
  49. package/esm/src/drizzle-field-builder.js +4 -4
  50. package/esm/src/drizzle-field-builder.js.map +1 -1
  51. package/esm/src/field-builder.js +2 -2
  52. package/esm/src/field-builder.js.map +1 -1
  53. package/esm/src/global-types.js +1 -1
  54. package/esm/src/global-types.js.map +1 -1
  55. package/esm/src/index.js +4 -4
  56. package/esm/src/index.js.map +1 -1
  57. package/esm/src/interface-ref.js.map +1 -1
  58. package/esm/src/model-loader.js +6 -5
  59. package/esm/src/model-loader.js.map +1 -1
  60. package/esm/src/object-ref.js +4 -2
  61. package/esm/src/object-ref.js.map +1 -1
  62. package/esm/src/schema-builder.js +5 -5
  63. package/esm/src/schema-builder.js.map +1 -1
  64. package/esm/src/types.js.map +1 -1
  65. package/esm/src/utils/config.js.map +1 -1
  66. package/esm/src/utils/cursors.js +6 -6
  67. package/esm/src/utils/cursors.js.map +1 -1
  68. package/esm/src/utils/deep-equal.js +1 -1
  69. package/esm/src/utils/deep-equal.js.map +1 -1
  70. package/esm/src/utils/drizzle-graphql.js +44 -21
  71. package/esm/src/utils/drizzle-graphql.js.map +1 -1
  72. package/esm/src/utils/loader-map.js +4 -5
  73. package/esm/src/utils/loader-map.js.map +1 -1
  74. package/esm/src/utils/map-query.js +1 -3
  75. package/esm/src/utils/map-query.js.map +1 -1
  76. package/esm/src/utils/refs.js.map +1 -1
  77. package/esm/src/utils/selections.js +3 -3
  78. package/esm/src/utils/selections.js.map +1 -1
  79. package/esm/src/utils/usage.js +0 -1
  80. package/esm/src/utils/usage.js.map +1 -1
  81. package/esm/types.d.ts +10 -9
  82. package/esm/types.d.ts.map +1 -1
  83. package/esm/utils/config.d.ts +2 -2
  84. package/esm/utils/config.d.ts.map +1 -1
  85. package/esm/utils/cursors.d.ts +7 -7
  86. package/esm/utils/cursors.d.ts.map +1 -1
  87. package/esm/utils/deep-equal.d.ts.map +1 -1
  88. package/esm/utils/drizzle-graphql.d.ts +1 -1
  89. package/esm/utils/drizzle-graphql.d.ts.map +1 -1
  90. package/esm/utils/loader-map.d.ts +1 -1
  91. package/esm/utils/loader-map.d.ts.map +1 -1
  92. package/esm/utils/map-query.d.ts +3 -3
  93. package/esm/utils/map-query.d.ts.map +1 -1
  94. package/esm/utils/refs.d.ts +2 -2
  95. package/esm/utils/refs.d.ts.map +1 -1
  96. package/esm/utils/selections.d.ts +3 -3
  97. package/esm/utils/selections.d.ts.map +1 -1
  98. package/esm/utils/usage.d.ts.map +1 -1
  99. package/lib/src/drizzle-field-builder.js +3 -3
  100. package/lib/src/drizzle-field-builder.js.map +1 -1
  101. package/lib/src/field-builder.js +2 -2
  102. package/lib/src/field-builder.js.map +1 -1
  103. package/lib/src/global-types.js +1 -1
  104. package/lib/src/global-types.js.map +1 -1
  105. package/lib/src/index.js +4 -4
  106. package/lib/src/index.js.map +1 -1
  107. package/lib/src/interface-ref.js.map +1 -1
  108. package/lib/src/model-loader.js +7 -5
  109. package/lib/src/model-loader.js.map +1 -1
  110. package/lib/src/object-ref.js +3 -1
  111. package/lib/src/object-ref.js.map +1 -1
  112. package/lib/src/schema-builder.js +5 -5
  113. package/lib/src/schema-builder.js.map +1 -1
  114. package/lib/src/types.js.map +1 -1
  115. package/lib/src/utils/config.js.map +1 -1
  116. package/lib/src/utils/cursors.js +7 -6
  117. package/lib/src/utils/cursors.js.map +1 -1
  118. package/lib/src/utils/deep-equal.js +1 -1
  119. package/lib/src/utils/deep-equal.js.map +1 -1
  120. package/lib/src/utils/drizzle-graphql.js +53 -21
  121. package/lib/src/utils/drizzle-graphql.js.map +1 -1
  122. package/lib/src/utils/loader-map.js +4 -5
  123. package/lib/src/utils/loader-map.js.map +1 -1
  124. package/lib/src/utils/map-query.js +2 -4
  125. package/lib/src/utils/map-query.js.map +1 -1
  126. package/lib/src/utils/refs.js.map +1 -1
  127. package/lib/src/utils/selections.js +4 -4
  128. package/lib/src/utils/selections.js.map +1 -1
  129. package/lib/src/utils/usage.js +0 -1
  130. package/lib/src/utils/usage.js.map +1 -1
  131. package/package.json +11 -11
  132. package/src/drizzle-field-builder.ts +28 -21
  133. package/src/field-builder.ts +9 -9
  134. package/src/global-types.ts +28 -20
  135. package/src/index.ts +29 -36
  136. package/src/interface-ref.ts +2 -2
  137. package/src/model-loader.ts +10 -16
  138. package/src/node-ref.ts +1 -1
  139. package/src/object-ref.ts +5 -3
  140. package/src/schema-builder.ts +18 -18
  141. package/src/types.ts +39 -46
  142. package/src/utils/config.ts +6 -2
  143. package/src/utils/cursors.ts +21 -22
  144. package/src/utils/deep-equal.ts +0 -1
  145. package/src/utils/drizzle-graphql.ts +53 -14
  146. package/src/utils/loader-map.ts +5 -7
  147. package/src/utils/map-query.ts +20 -23
  148. package/src/utils/refs.ts +2 -2
  149. package/src/utils/selections.ts +8 -9
  150. package/src/utils/usage.ts +0 -2
package/src/types.ts CHANGED
@@ -1,4 +1,30 @@
1
1
  import {
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 InterfaceRef,
14
+ type InterfaceTypeOptions,
15
+ type ListResolveValue,
16
+ type MaybePromise,
17
+ type Normalize,
18
+ type ObjectRef,
19
+ type ObjectTypeOptions,
20
+ type OutputShape,
21
+ type OutputType,
22
+ type SchemaTypes,
23
+ type ShapeFromTypeParam,
24
+ type TypeParam,
25
+ typeBrandKey,
26
+ } from '@pothos/core';
27
+ import type {
2
28
  BuildQueryResult,
3
29
  Column,
4
30
  DBQueryConfig,
@@ -9,40 +35,13 @@ import {
9
35
  TableRelationalConfig,
10
36
  TablesRelationalConfig,
11
37
  } from 'drizzle-orm';
12
- import { FieldNode, GraphQLResolveInfo } from 'graphql';
13
- import {
14
- ArgumentRef,
15
- FieldKind,
16
- FieldMap,
17
- FieldNullability,
18
- FieldOptionsFromKind,
19
- InferredFieldOptionKeys,
20
- InferredFieldOptionsByKind,
21
- InputFieldMap,
22
- InputFieldsFromShape,
23
- InputShapeFromFields,
24
- InterfaceParam,
25
- InterfaceRef,
26
- InterfaceTypeOptions,
27
- ListResolveValue,
28
- MaybePromise,
29
- Normalize,
30
- ObjectRef,
31
- ObjectTypeOptions,
32
- OutputShape,
33
- OutputType,
34
- SchemaTypes,
35
- ShapeFromTypeParam,
36
- typeBrandKey,
37
- TypeParam,
38
- } from '@pothos/core';
38
+ import type { FieldNode, GraphQLResolveInfo } from 'graphql';
39
39
  import type { DrizzleObjectFieldBuilder } from './drizzle-field-builder';
40
- import { type DrizzleRef } from './interface-ref';
41
- import { IndirectInclude } from './utils/map-query';
42
- import { SelectionMap } from './utils/selections';
40
+ import type { DrizzleRef } from './interface-ref';
41
+ import type { IndirectInclude } from './utils/map-query';
42
+ import type { SelectionMap } from './utils/selections';
43
43
 
44
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
45
- export interface DrizzlePluginOptions<Types extends SchemaTypes> {
44
+ export interface DrizzlePluginOptions<_Types extends SchemaTypes> {
46
45
  client: { _: Partial<RelationalSchemaConfig<TablesRelationalConfig>>; query: {} };
47
46
  maxConnectionSize?: number;
48
47
  defaultConnectionSize?: number;
@@ -238,6 +237,7 @@ export type DrizzleObjectFieldOptions<
238
237
  : BuildQueryResult<
239
238
  Types['DrizzleRelationSchema'],
240
239
  ExtractTable<Types, ParentShape>,
240
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
241
241
  Record<string, unknown> & (Select extends (...args: any[]) => infer R ? R : Select)
242
242
  > &
243
243
  ParentShape,
@@ -338,6 +338,7 @@ export type RelatedFieldOptions<
338
338
  export type VariantFieldOptions<
339
339
  Types extends SchemaTypes,
340
340
  Table extends keyof Types['DrizzleRelationSchema'],
341
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
341
342
  Variant extends DrizzleRef<any, Table> | Table,
342
343
  Args extends InputFieldMap,
343
344
  isNull,
@@ -348,6 +349,7 @@ export type VariantFieldOptions<
348
349
  FieldOptionsFromKind<
349
350
  Types,
350
351
  Shape,
352
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
351
353
  Variant extends DrizzleRef<any> ? Variant : DrizzleRef<any, Table>,
352
354
  unknown extends isNull ? false : true,
353
355
  Args,
@@ -367,6 +369,7 @@ export type VariantFieldOptions<
367
369
  Types['DrizzleRelationSchema'],
368
370
  ExtractTable<Types, Shape>,
369
371
  Record<string, unknown> &
372
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
370
373
  (ResolveShape extends (...args: any[]) => infer R ? R : ResolveShape)
371
374
  > &
372
375
  Shape,
@@ -465,16 +468,14 @@ export type ListRelation<T extends TableRelationalConfig> = {
465
468
  export type DrizzleConnectionFieldOptions<
466
469
  Types extends SchemaTypes,
467
470
  ParentShape,
468
- Type extends
469
- | DrizzleRef<any, keyof Types['DrizzleRelationSchema']>
470
- | keyof Types['DrizzleRelationSchema'],
471
+ Type extends // biome-ignore lint/suspicious/noExplicitAny: <explanation>
472
+ DrizzleRef<any, keyof Types['DrizzleRelationSchema']> | keyof Types['DrizzleRelationSchema'],
471
473
  TableConfig extends TableRelationalConfig,
472
474
  Param extends OutputType<Types>,
473
475
  Nullable extends boolean,
474
476
  Args extends InputFieldMap,
475
477
  ResolveReturnShape,
476
478
  Kind extends FieldKind,
477
- // eslint-disable-next-line @typescript-eslint/sort-type-constituents
478
479
  > = Omit<
479
480
  FieldOptionsFromKind<
480
481
  Types,
@@ -510,15 +511,7 @@ export type DrizzleConnectionFieldOptions<
510
511
  maxSize?: number | ((args: ConnectionArgs, ctx: Types['Context']) => number);
511
512
 
512
513
  resolve: (
513
- query: <
514
- T extends QueryForRelatedConnection<
515
- Types,
516
- Types['DrizzleRelationSchema'][Type extends DrizzleRef<any, infer K>
517
- ? K
518
- : Type & keyof Types['DrizzleRelationSchema']],
519
- ConnectionArgs
520
- >,
521
- >(
514
+ query: <T extends QueryForRelatedConnection<Types, TableConfig, ConnectionArgs>>(
522
515
  selection?: T,
523
516
  ) => Omit<T, 'orderBy'> & { orderBy: SQL },
524
517
  parent: ParentShape,
@@ -542,7 +535,6 @@ export type RelatedConnectionOptions<
542
535
  Args extends InputFieldMap,
543
536
  NodeTable extends
544
537
  TableRelationalConfig = Types['DrizzleRelationSchema'][Table['relations'][Field]['referencedTable']['_']['name']],
545
- // eslint-disable-next-line @typescript-eslint/sort-type-constituents
546
538
  > = Omit<
547
539
  PothosSchemaTypes.ObjectFieldOptions<
548
540
  Types,
@@ -584,6 +576,7 @@ export type RelatedConnectionOptions<
584
576
  >
585
577
  >;
586
578
  query: QueryForRelatedConnection<Types, NodeTable, ConnectionArgs>;
579
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
587
580
  type?: DrizzleRef<any, Table['relations'][Field]['referencedTable']['_']['name']>;
588
581
 
589
582
  defaultSize?: number | ((args: ConnectionArgs, ctx: Types['Context']) => number);
@@ -1,5 +1,9 @@
1
- import { createContextCache, SchemaTypes } from '@pothos/core';
2
- import { RelationalSchemaConfig, TableRelationalConfig, TablesRelationalConfig } from 'drizzle-orm';
1
+ import { type SchemaTypes, createContextCache } from '@pothos/core';
2
+ import type {
3
+ RelationalSchemaConfig,
4
+ TableRelationalConfig,
5
+ TablesRelationalConfig,
6
+ } from 'drizzle-orm';
3
7
 
4
8
  export interface PothosDrizzleSchemaConfig extends RelationalSchemaConfig<TablesRelationalConfig> {
5
9
  dbToSchema: Record<string, TableRelationalConfig>;
@@ -1,25 +1,23 @@
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 {
10
- Column,
9
+ type Column,
10
+ type DBQueryConfig,
11
+ type SQL,
12
+ type TableRelationalConfig,
11
13
  getOperators,
12
14
  getOrderByOperators,
13
- RelationalSchemaConfig,
14
- SQL,
15
- TableRelationalConfig,
16
- TablesRelationalConfig,
17
15
  } from 'drizzle-orm';
18
- import { ConnectionOrderBy, QueryForDrizzleConnection } from '../types';
19
- import { SelectionMap } from './selections';
20
- import { GraphQLResolveInfo } from 'graphql';
16
+ import type { GraphQLResolveInfo } from 'graphql';
17
+ import type { ConnectionOrderBy, QueryForDrizzleConnection } from '../types';
18
+ import type { PothosDrizzleSchemaConfig } from './config';
21
19
  import { queryFromInfo } from './map-query';
22
- import { PothosDrizzleSchemaConfig } from './config';
20
+ import type { SelectionMap } from './selections';
23
21
 
24
22
  const DEFAULT_MAX_SIZE = 100;
25
23
  const DEFAULT_SIZE = 20;
@@ -224,7 +222,8 @@ function parseOrderBy(orderBy: ConnectionOrderBy, invert: boolean) {
224
222
  direction: asc,
225
223
  column: field.asc,
226
224
  };
227
- } else if (typeof field === 'object' && 'desc' in field) {
225
+ }
226
+ if (typeof field === 'object' && 'desc' in field) {
228
227
  return {
229
228
  direction: desc,
230
229
  column: field.desc,
@@ -297,11 +296,11 @@ export function drizzleCursorConnectionQuery({
297
296
 
298
297
  const columns: Record<string, boolean> = {};
299
298
 
300
- parsedOrderBy.columns.forEach((column) => {
299
+ for (const column of parsedOrderBy.columns) {
301
300
  columns[column.name] = true;
302
- });
301
+ }
303
302
 
304
- let whereClauses: (SQL | undefined)[] = where ? [where] : [];
303
+ const whereClauses: (SQL | undefined)[] = where ? [where] : [];
305
304
 
306
305
  if (cursor) {
307
306
  const cursorParser = getCursorParser(parsedOrderBy.columns);
@@ -345,7 +344,7 @@ export function wrapConnectionResult<T extends {}>(
345
344
  args: PothosSchemaTypes.DefaultConnectionArguments,
346
345
  limit: number,
347
346
  cursor: (node: T) => string,
348
- resolveNode?: (node: unknown) => unknown,
347
+ resolveNode?: (node: Record<string, unknown>) => unknown,
349
348
  ) {
350
349
  const gotFullResults = results.length === Math.abs(limit);
351
350
  const hasNextPage = args.before ? true : args.last ? false : gotFullResults;
@@ -365,7 +364,7 @@ export function wrapConnectionResult<T extends {}>(
365
364
  },
366
365
  };
367
366
 
368
- const edges = nodes.map((value, index) =>
367
+ const edges = nodes.map((value) =>
369
368
  value == null
370
369
  ? null
371
370
  : resolveNode
@@ -403,8 +402,8 @@ export async function resolveDrizzleCursorConnection<T extends {}>(
403
402
  queryFn: (query: QueryForDrizzleConnection<SchemaTypes, TableRelationalConfig>) => SelectionMap,
404
403
  ) => MaybePromise<readonly T[]>,
405
404
  ) {
406
- let query;
407
- let formatter;
405
+ let query: DBQueryConfig<'many', false>;
406
+ let formatter: (node: Record<string, unknown>) => string;
408
407
  const results = await resolve((q) => {
409
408
  const { cursorColumns, ...connectionQuery } = drizzleCursorConnectionQuery({
410
409
  ...options,
@@ -442,5 +441,5 @@ export async function resolveDrizzleCursorConnection<T extends {}>(
442
441
  return results;
443
442
  }
444
443
 
445
- return wrapConnectionResult(results, options.args, query!.limit, formatter!);
444
+ return wrapConnectionResult(results, options.args, query!.limit as number, formatter!);
446
445
  }
@@ -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,12 +1,22 @@
1
- import { asc, Column, desc, getOperators, SQL, Table, TableRelationalConfig } from 'drizzle-orm';
1
+ import {
2
+ type Column,
3
+ type SQL,
4
+ Table,
5
+ type TableRelationalConfig,
6
+ asc,
7
+ desc,
8
+ getOperators,
9
+ } from 'drizzle-orm';
2
10
  import { GraphQLError } from 'graphql';
3
11
 
12
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
4
13
  export const remapFromGraphQLCore = (value: any, column: Column, columnName: string) => {
5
14
  switch (column.dataType) {
6
15
  case 'date': {
7
16
  const formatted = new Date(value);
8
- if (Number.isNaN(formatted.getTime()))
17
+ if (Number.isNaN(formatted.getTime())) {
9
18
  throw new GraphQLError(`Field '${columnName}' is not a valid date!`);
19
+ }
10
20
 
11
21
  return formatted;
12
22
  }
@@ -20,7 +30,9 @@ export const remapFromGraphQLCore = (value: any, column: Column, columnName: str
20
30
  }
21
31
 
22
32
  case 'json': {
23
- if (column.columnType === 'PgGeometryObject') return value;
33
+ if (column.columnType === 'PgGeometryObject') {
34
+ return value;
35
+ }
24
36
 
25
37
  try {
26
38
  return JSON.parse(value);
@@ -48,7 +60,7 @@ export const remapFromGraphQLCore = (value: any, column: Column, columnName: str
48
60
  case 'bigint': {
49
61
  try {
50
62
  return BigInt(value);
51
- } catch (error) {
63
+ } catch (_error) {
52
64
  throw new GraphQLError(`Field '${columnName}' is not a BigInt!`);
53
65
  }
54
66
  }
@@ -60,6 +72,7 @@ export const remapFromGraphQLCore = (value: any, column: Column, columnName: str
60
72
  };
61
73
 
62
74
  export const remapFromGraphQLSingleInput = (
75
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
63
76
  queryInput: Record<string, any>,
64
77
  table: TableRelationalConfig,
65
78
  ) => {
@@ -68,7 +81,9 @@ export const remapFromGraphQLSingleInput = (
68
81
  delete queryInput[key];
69
82
  } else {
70
83
  const column = table.columns[key];
71
- if (!column) throw new GraphQLError(`Unknown column: ${key}`);
84
+ if (!column) {
85
+ throw new GraphQLError(`Unknown column: ${key}`);
86
+ }
72
87
 
73
88
  if (value === null && column.notNull) {
74
89
  delete queryInput[key];
@@ -83,10 +98,13 @@ export const remapFromGraphQLSingleInput = (
83
98
  };
84
99
 
85
100
  export const remapFromGraphQLArrayInput = (
101
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
86
102
  queryInput: Record<string, any>[],
87
103
  table: TableRelationalConfig,
88
104
  ) => {
89
- for (const entry of queryInput) remapFromGraphQLSingleInput(entry, table);
105
+ for (const entry of queryInput) {
106
+ remapFromGraphQLSingleInput(entry, table);
107
+ }
90
108
 
91
109
  return queryInput;
92
110
  };
@@ -100,6 +118,7 @@ export type OrderByArgs<TTable extends TableRelationalConfig> = {
100
118
 
101
119
  export const extractOrderBy = <
102
120
  TTable extends TableRelationalConfig,
121
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
103
122
  TArgs extends OrderByArgs<any> = OrderByArgs<TTable>,
104
123
  >(
105
124
  table: TTable,
@@ -110,7 +129,9 @@ export const extractOrderBy = <
110
129
  for (const [column, config] of Object.entries(orderArgs).sort(
111
130
  (a, b) => (b[1]?.priority ?? 0) - (a[1]?.priority ?? 0),
112
131
  )) {
113
- if (!config) continue;
132
+ if (!config) {
133
+ continue;
134
+ }
114
135
  const { direction } = config;
115
136
 
116
137
  res.push(direction === 'asc' ? asc(table.columns[column]!) : desc(table.columns[column]!));
@@ -126,7 +147,10 @@ export const extractFiltersColumn = <TColumn extends Column>(
126
147
  columnName: string,
127
148
  operators: Record<string, unknown> & { OR?: Record<string, unknown>[] },
128
149
  ): SQL | undefined => {
129
- if (!operators.OR?.length) delete operators.OR;
150
+ if (!operators.OR?.length) {
151
+ // biome-ignore lint/performance/noDelete: <explanation>
152
+ delete operators.OR;
153
+ }
130
154
 
131
155
  const entries = Object.entries(operators);
132
156
 
@@ -142,6 +166,7 @@ export const extractFiltersColumn = <TColumn extends Column>(
142
166
  for (const variant of operators.OR) {
143
167
  const extracted = extractFiltersColumn(column, columnName, variant);
144
168
 
169
+ // biome-ignore lint/style/useBlockStatements: <explanation>
145
170
  if (extracted) variants.push(extracted);
146
171
  }
147
172
 
@@ -150,6 +175,7 @@ export const extractFiltersColumn = <TColumn extends Column>(
150
175
 
151
176
  const variants = [] as SQL[];
152
177
  for (const [operatorName, operatorValue] of entries) {
178
+ // biome-ignore lint/style/useBlockStatements: <explanation>
153
179
  if (operatorValue === null || operatorValue === false) continue;
154
180
 
155
181
  switch (operatorName) {
@@ -158,11 +184,12 @@ export const extractFiltersColumn = <TColumn extends Column>(
158
184
  case 'gt':
159
185
  case 'gte':
160
186
  case 'lt':
161
- case 'lte':
187
+ case 'lte': {
162
188
  const singleValue = remapFromGraphQLCore(operatorValue, column, columnName);
163
189
  variants.push(ops[operatorName](column, singleValue));
164
190
 
165
191
  break;
192
+ }
166
193
  case 'like':
167
194
  case 'notLike':
168
195
  case 'ilike':
@@ -170,18 +197,21 @@ export const extractFiltersColumn = <TColumn extends Column>(
170
197
  variants.push(ops[operatorName](column, operatorValue as string));
171
198
  break;
172
199
  case 'inArray':
173
- case 'notInArray':
200
+ case 'notInArray': {
201
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
174
202
  if (!(operatorValue as any[]).length) {
175
203
  throw new GraphQLError(
176
204
  `WHERE ${columnName}: Unable to use operator ${operatorName} with an empty array!`,
177
205
  );
178
206
  }
207
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
179
208
  const arrayValue = (operatorValue as any[]).map((val) =>
180
209
  remapFromGraphQLCore(val, column, columnName),
181
210
  );
182
211
 
183
212
  variants.push(ops[operatorName](column, arrayValue));
184
213
  break;
214
+ }
185
215
  case 'isNull':
186
216
  case 'isNotNull':
187
217
  variants.push(ops[operatorName](column));
@@ -201,10 +231,15 @@ export const extractFilters = <TTable extends TableRelationalConfig>(
201
231
  OR?: Record<string, unknown>[];
202
232
  },
203
233
  ): SQL | undefined => {
204
- if (!filters.OR?.length) delete filters.OR;
234
+ if (!filters.OR?.length) {
235
+ // biome-ignore lint/performance/noDelete: <explanation>
236
+ delete filters.OR;
237
+ }
205
238
 
206
239
  const entries = Object.entries(filters);
207
- if (!entries.length) return;
240
+ if (!entries.length) {
241
+ return;
242
+ }
208
243
 
209
244
  if (filters.OR) {
210
245
  if (entries.length > 1) {
@@ -217,7 +252,9 @@ export const extractFilters = <TTable extends TableRelationalConfig>(
217
252
 
218
253
  for (const variant of filters.OR) {
219
254
  const extracted = extractFilters(table, tableName, variant);
220
- if (extracted) variants.push(extracted);
255
+ if (extracted) {
256
+ variants.push(extracted);
257
+ }
221
258
  }
222
259
 
223
260
  return variants.length ? (variants.length > 1 ? ops.or(...variants) : variants[0]) : undefined;
@@ -225,7 +262,9 @@ export const extractFilters = <TTable extends TableRelationalConfig>(
225
262
 
226
263
  const variants = [] as SQL[];
227
264
  for (const [columnName, operators] of entries) {
228
- if (operators === null) continue;
265
+ if (operators === null) {
266
+ continue;
267
+ }
229
268
 
230
269
  const column = table.columns[columnName]!;
231
270
  variants.push(extractFiltersColumn(column, columnName, operators as Record<string, unknown>)!);
@@ -1,5 +1,5 @@
1
- import { GraphQLResolveInfo } from 'graphql';
2
1
  import { createContextCache } from '@pothos/core';
2
+ import type { GraphQLResolveInfo } from 'graphql';
3
3
 
4
4
  export type LoaderMappings = Record<
5
5
  string,
@@ -11,7 +11,7 @@ export type LoaderMappings = Record<
11
11
  }
12
12
  >;
13
13
 
14
- const cache = createContextCache((ctx) => new Map<string, LoaderMappings>());
14
+ const cache = createContextCache(() => new Map<string, LoaderMappings>());
15
15
 
16
16
  export function cacheKey(type: string, path: GraphQLResolveInfo['path'], subPath: string[] = []) {
17
17
  let key = '';
@@ -32,15 +32,13 @@ export function cacheKey(type: string, path: GraphQLResolveInfo['path'], subPath
32
32
  }
33
33
 
34
34
  export function setLoaderMappings(ctx: object, info: GraphQLResolveInfo, value: LoaderMappings) {
35
- Object.keys(value).forEach((field) => {
36
- const map = cache(ctx);
37
-
38
- const mapping = value[field];
35
+ const map = cache(ctx);
36
+ for (const [field, mapping] of Object.entries(value)) {
39
37
  const subPath = [...mapping.indirectPath, field];
40
38
  const key = cacheKey(mapping.type, info.path, subPath);
41
39
 
42
40
  map.set(key, mapping.mappings);
43
- });
41
+ }
44
42
  }
45
43
 
46
44
  export function getLoaderMapping(ctx: object, path: GraphQLResolveInfo['path'], type: string) {
@@ -1,42 +1,41 @@
1
- /* eslint-disable no-continue */
1
+ import { PothosValidationError } from '@pothos/core';
2
2
  import {
3
- DBQueryConfig,
3
+ type DBQueryConfig,
4
4
  RelationalSchemaConfig,
5
- TableRelationalConfig,
5
+ type TableRelationalConfig,
6
6
  TablesRelationalConfig,
7
7
  } from 'drizzle-orm';
8
8
  import {
9
- FieldNode,
10
- FragmentDefinitionNode,
9
+ type FieldNode,
10
+ type FragmentDefinitionNode,
11
+ type GraphQLField,
12
+ GraphQLIncludeDirective,
13
+ type GraphQLInterfaceType,
14
+ type GraphQLNamedType,
15
+ type GraphQLObjectType,
16
+ type GraphQLResolveInfo,
17
+ GraphQLSkipDirective,
18
+ type InlineFragmentNode,
19
+ Kind,
20
+ type SelectionSetNode,
11
21
  getArgumentValues,
12
22
  getDirectiveValues,
13
23
  getNamedType,
14
- GraphQLField,
15
- GraphQLIncludeDirective,
16
- GraphQLInterfaceType,
17
- GraphQLNamedType,
18
- GraphQLObjectType,
19
- GraphQLResolveInfo,
20
- GraphQLSkipDirective,
21
- InlineFragmentNode,
22
24
  isInterfaceType,
23
25
  isObjectType,
24
- Kind,
25
- SelectionSetNode,
26
26
  } from 'graphql';
27
- import { PothosValidationError } from '@pothos/core';
28
- import { type DrizzleFieldSelection } from '../types';
29
- import { LoaderMappings, setLoaderMappings } from './loader-map';
27
+ import type { DrizzleFieldSelection } from '../types';
28
+ import type { PothosDrizzleSchemaConfig } from './config';
29
+ import { type LoaderMappings, setLoaderMappings } from './loader-map';
30
30
  import {
31
+ type SelectionMap,
32
+ type SelectionState,
31
33
  createState,
32
34
  mergeSelection,
33
35
  selectionCompatible,
34
- SelectionMap,
35
- SelectionState,
36
36
  selectionToQuery,
37
37
  } from './selections';
38
38
  import { wrapWithUsageCheck } from './usage';
39
- import { PothosDrizzleSchemaConfig } from './config';
40
39
 
41
40
  export interface IndirectInclude {
42
41
  getType: () => string;
@@ -348,7 +347,6 @@ function addFieldSelection(
348
347
  );
349
348
  }
350
349
  addTypeSelectionsForField(config, returnType, context, info, fieldState, selection, []);
351
- // eslint-disable-next-line prefer-destructuring
352
350
  mappings = fieldState.mappings;
353
351
  return selectionToQuery(fieldState);
354
352
  },
@@ -376,7 +374,6 @@ function addFieldSelection(
376
374
 
377
375
  if (fieldSelect && selectionCompatible(state, fieldSelectionMap, true)) {
378
376
  mergeSelection(config, state, fieldSelectionMap);
379
- // eslint-disable-next-line no-param-reassign
380
377
  state.mappings[selection.alias?.value ?? selection.name.value] = {
381
378
  field: selection.name.value,
382
379
  type: type.name,
package/src/utils/refs.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { SchemaTypes } from '@pothos/core';
2
- import { DrizzleInterfaceRef, DrizzleRef } from '../interface-ref';
1
+ import type { SchemaTypes } from '@pothos/core';
2
+ import { DrizzleInterfaceRef, type DrizzleRef } from '../interface-ref';
3
3
  import { DrizzleObjectRef } from '../object-ref';
4
4
 
5
5
  export const refMap = new WeakMap<object, Map<string, DrizzleRef<never>>>();
@@ -1,16 +1,15 @@
1
- /* eslint-disable no-param-reassign */
1
+ import { PothosValidationError } from '@pothos/core';
2
2
  import {
3
- DBQueryConfig,
3
+ type DBQueryConfig,
4
4
  RelationalSchemaConfig,
5
- SQL,
6
- TableRelationalConfig,
5
+ type SQL,
6
+ type TableRelationalConfig,
7
7
  TablesRelationalConfig,
8
8
  getOperators,
9
9
  } from 'drizzle-orm';
10
- import { PothosValidationError } from '@pothos/core';
10
+ import type { PothosDrizzleSchemaConfig } from './config';
11
11
  import { deepEqual } from './deep-equal';
12
- import { LoaderMappings } from './loader-map';
13
- import { PothosDrizzleSchemaConfig } from './config';
12
+ import type { LoaderMappings } from './loader-map';
14
13
 
15
14
  export interface SelectionState {
16
15
  table: TableRelationalConfig;
@@ -123,7 +122,7 @@ export function mergeSelection(
123
122
  { with: withSelection, extras, columns, ...query }: SelectionMap,
124
123
  ) {
125
124
  if (withSelection) {
126
- Object.entries(withSelection).forEach(([key, value]) => {
125
+ for (const [key, value] of Object.entries(withSelection)) {
127
126
  const relation = state.table.relations[key];
128
127
 
129
128
  if (!relation) {
@@ -131,7 +130,7 @@ export function mergeSelection(
131
130
  }
132
131
 
133
132
  merge(config.dbToSchema[relation.referencedTableName], key, value as SelectionMap | boolean);
134
- });
133
+ }
135
134
  }
136
135
 
137
136
  if (Object.keys(query).length > 0) {
@@ -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