@pothos/plugin-drizzle 0.17.4 → 0.17.6

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 (128) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dts/connection-helpers.d.ts +3 -3
  3. package/dts/connection-helpers.d.ts.map +1 -1
  4. package/dts/drizzle-field-builder.d.ts +2 -2
  5. package/dts/drizzle-field-builder.d.ts.map +1 -1
  6. package/dts/global-types.d.ts +6 -6
  7. package/dts/global-types.d.ts.map +1 -1
  8. package/dts/index.d.ts +8 -8
  9. package/dts/index.d.ts.map +1 -1
  10. package/dts/interface-ref.d.ts +2 -2
  11. package/dts/interface-ref.d.ts.map +1 -1
  12. package/dts/model-loader.d.ts +2 -2
  13. package/dts/model-loader.d.ts.map +1 -1
  14. package/dts/node-ref.d.ts +1 -1
  15. package/dts/node-ref.d.ts.map +1 -1
  16. package/dts/object-ref.d.ts +1 -1
  17. package/dts/object-ref.d.ts.map +1 -1
  18. package/dts/types.d.ts +5 -5
  19. package/dts/types.d.ts.map +1 -1
  20. package/dts/utils/cursors.d.ts +4 -4
  21. package/dts/utils/cursors.d.ts.map +1 -1
  22. package/dts/utils/map-query.d.ts +3 -3
  23. package/dts/utils/map-query.d.ts.map +1 -1
  24. package/dts/utils/refs.d.ts +1 -1
  25. package/dts/utils/refs.d.ts.map +1 -1
  26. package/dts/utils/selections.d.ts +3 -2
  27. package/dts/utils/selections.d.ts.map +1 -1
  28. package/esm/connection-helpers.d.ts +14 -16
  29. package/esm/connection-helpers.d.ts.map +1 -1
  30. package/esm/connection-helpers.js +28 -27
  31. package/esm/connection-helpers.js.map +1 -1
  32. package/esm/drizzle-field-builder.d.ts +60 -172
  33. package/esm/drizzle-field-builder.d.ts.map +1 -1
  34. package/esm/drizzle-field-builder.js +51 -50
  35. package/esm/drizzle-field-builder.js.map +1 -1
  36. package/esm/field-builder.d.ts +1 -1
  37. package/esm/field-builder.js +29 -28
  38. package/esm/field-builder.js.map +1 -1
  39. package/esm/global-types.d.ts +32 -60
  40. package/esm/global-types.d.ts.map +1 -1
  41. package/esm/global-types.js +3 -2
  42. package/esm/global-types.js.map +1 -1
  43. package/esm/index.d.ts +2 -2
  44. package/esm/index.d.ts.map +1 -1
  45. package/esm/index.js +15 -14
  46. package/esm/index.js.map +1 -1
  47. package/esm/interface-ref.d.ts +4 -4
  48. package/esm/interface-ref.d.ts.map +1 -1
  49. package/esm/interface-ref.js +4 -4
  50. package/esm/interface-ref.js.map +1 -1
  51. package/esm/model-loader.d.ts +2 -3
  52. package/esm/model-loader.d.ts.map +1 -1
  53. package/esm/model-loader.js +24 -25
  54. package/esm/model-loader.js.map +1 -1
  55. package/esm/node-ref.d.ts +2 -2
  56. package/esm/node-ref.d.ts.map +1 -1
  57. package/esm/node-ref.js +5 -5
  58. package/esm/node-ref.js.map +1 -1
  59. package/esm/object-ref.d.ts +3 -3
  60. package/esm/object-ref.d.ts.map +1 -1
  61. package/esm/object-ref.js +7 -7
  62. package/esm/schema-builder.d.ts +1 -1
  63. package/esm/schema-builder.js +133 -132
  64. package/esm/schema-builder.js.map +1 -1
  65. package/esm/types.d.ts +69 -83
  66. package/esm/types.d.ts.map +1 -1
  67. package/esm/types.js +3 -2
  68. package/esm/types.js.map +1 -1
  69. package/esm/utils/config.d.ts +2 -4
  70. package/esm/utils/config.js +14 -14
  71. package/esm/utils/cursors.d.ts +4 -4
  72. package/esm/utils/cursors.d.ts.map +1 -1
  73. package/esm/utils/cursors.js +90 -94
  74. package/esm/utils/cursors.js.map +1 -1
  75. package/esm/utils/deep-equal.d.ts +1 -1
  76. package/esm/utils/deep-equal.js +6 -5
  77. package/esm/utils/drizzle-graphql.d.ts +1 -1
  78. package/esm/utils/drizzle-graphql.js +232 -231
  79. package/esm/utils/loader-map.d.ts +3 -3
  80. package/esm/utils/loader-map.js +8 -7
  81. package/esm/utils/map-query.d.ts +2 -2
  82. package/esm/utils/map-query.d.ts.map +1 -1
  83. package/esm/utils/map-query.js +39 -43
  84. package/esm/utils/map-query.js.map +1 -1
  85. package/esm/utils/refs.d.ts +2 -2
  86. package/esm/utils/refs.d.ts.map +1 -1
  87. package/esm/utils/refs.js +5 -4
  88. package/esm/utils/refs.js.map +1 -1
  89. package/esm/utils/selections.d.ts +4 -3
  90. package/esm/utils/selections.d.ts.map +1 -1
  91. package/esm/utils/selections.js +30 -26
  92. package/esm/utils/selections.js.map +1 -1
  93. package/esm/utils/usage.d.ts +1 -1
  94. package/esm/utils/usage.js +9 -8
  95. package/lib/connection-helpers.js +7 -7
  96. package/lib/connection-helpers.js.map +1 -1
  97. package/lib/drizzle-field-builder.js +6 -5
  98. package/lib/drizzle-field-builder.js.map +1 -1
  99. package/lib/field-builder.js +4 -4
  100. package/lib/index.js +8 -8
  101. package/lib/interface-ref.js +1 -1
  102. package/lib/model-loader.js +4 -4
  103. package/lib/node-ref.js +1 -1
  104. package/lib/schema-builder.js +8 -8
  105. package/lib/types.js +1 -1
  106. package/lib/utils/cursors.js +6 -5
  107. package/lib/utils/cursors.js.map +1 -1
  108. package/lib/utils/map-query.js +3 -3
  109. package/lib/utils/refs.js +2 -2
  110. package/lib/utils/selections.js +14 -5
  111. package/lib/utils/selections.js.map +1 -1
  112. package/package.json +12 -13
  113. package/src/connection-helpers.ts +14 -9
  114. package/src/drizzle-field-builder.ts +8 -8
  115. package/src/field-builder.ts +7 -7
  116. package/src/global-types.ts +6 -6
  117. package/src/index.ts +11 -11
  118. package/src/interface-ref.ts +2 -2
  119. package/src/model-loader.ts +4 -4
  120. package/src/node-ref.ts +1 -1
  121. package/src/object-ref.ts +1 -1
  122. package/src/schema-builder.ts +9 -9
  123. package/src/types.ts +5 -5
  124. package/src/utils/config.ts +1 -1
  125. package/src/utils/cursors.ts +8 -8
  126. package/src/utils/map-query.ts +5 -5
  127. package/src/utils/refs.ts +2 -2
  128. package/src/utils/selections.ts +15 -7
@@ -37,7 +37,7 @@ import {
37
37
  isInterfaceType,
38
38
  isObjectType,
39
39
  } from 'graphql';
40
- import type { DrizzleRef } from './interface-ref';
40
+ import type { DrizzleRef } from './interface-ref.js';
41
41
  import type {
42
42
  DrizzleConnectionShape,
43
43
  ListRelation,
@@ -48,15 +48,15 @@ import type {
48
48
  ShapeFromConnection,
49
49
  TypesForRelation,
50
50
  VariantFieldOptions,
51
- } from './types';
52
- import { getClient, getSchemaConfig } from './utils/config';
51
+ } from './types.js';
52
+ import { getClient, getSchemaConfig } from './utils/config.js';
53
53
  import {
54
54
  drizzleCursorConnectionQuery,
55
55
  getCursorFormatter,
56
56
  wrapConnectionResult,
57
- } from './utils/cursors';
58
- import { getRefFromModel } from './utils/refs';
59
- import type { SelectionMap } from './utils/selections';
57
+ } from './utils/cursors.js';
58
+ import { getRefFromModel } from './utils/refs.js';
59
+ import { omitUndefinedKeys, type SelectionMap } from './utils/selections.js';
60
60
 
61
61
  // Workaround for FieldKind not being extended on Builder classes
62
62
  const RootBuilder: {
@@ -526,7 +526,7 @@ export class DrizzleObjectFieldBuilder<
526
526
  const relQuery = {
527
527
  columns: {},
528
528
  with: {
529
- [name]: {
529
+ [name]: omitUndefinedKeys({
530
530
  ...nestedQuery(query),
531
531
  ...((typeof query === 'function'
532
532
  ? (query as (args: {}, context: {}, pathInfo: PathInfo) => {})(
@@ -535,7 +535,7 @@ export class DrizzleObjectFieldBuilder<
535
535
  pathInfo,
536
536
  )
537
537
  : query) as {}),
538
- },
538
+ }),
539
539
  },
540
540
  };
541
541
 
@@ -3,13 +3,13 @@ import { type FieldKind, ObjectRef, RootFieldBuilder, type SchemaTypes } from '@
3
3
  import type { TableRelationalConfig } from 'drizzle-orm';
4
4
  import type { GraphQLResolveInfo } from 'graphql';
5
5
  import { isInterfaceType, isObjectType, Kind } from 'graphql';
6
- import type { DrizzleRef } from './interface-ref';
7
- import type { DrizzleConnectionFieldOptions } from './types';
8
- import { getSchemaConfig } from './utils/config';
9
- import { resolveDrizzleCursorConnection } from './utils/cursors';
10
- import { queryFromInfo } from './utils/map-query';
11
- import { getRefFromModel } from './utils/refs';
12
- import type { SelectionMap } from './utils/selections';
6
+ import type { DrizzleRef } from './interface-ref.js';
7
+ import type { DrizzleConnectionFieldOptions } from './types.js';
8
+ import { getSchemaConfig } from './utils/config.js';
9
+ import { resolveDrizzleCursorConnection } from './utils/cursors.js';
10
+ import { queryFromInfo } from './utils/map-query.js';
11
+ import { getRefFromModel } from './utils/refs.js';
12
+ import type { SelectionMap } from './utils/selections.js';
13
13
 
14
14
  const fieldBuilderProto = RootFieldBuilder.prototype as PothosSchemaTypes.RootFieldBuilder<
15
15
  SchemaTypes,
@@ -17,11 +17,11 @@ import type {
17
17
  TableRelationalConfig,
18
18
  TablesRelationalConfig,
19
19
  } from 'drizzle-orm';
20
- import type { PothosDrizzlePlugin } from '.';
21
- import type { DrizzleObjectFieldBuilder } from './drizzle-field-builder';
22
- import type { DrizzleInterfaceRef, DrizzleRef } from './interface-ref';
23
- import type { DrizzleNodeRef } from './node-ref';
24
- import type { DrizzleObjectRef, drizzleTableKey } from './object-ref';
20
+ import type { DrizzleObjectFieldBuilder } from './drizzle-field-builder.js';
21
+ import type { PothosDrizzlePlugin } from './index.js';
22
+ import type { DrizzleInterfaceRef, DrizzleRef } from './interface-ref.js';
23
+ import type { DrizzleNodeRef } from './node-ref.js';
24
+ import type { DrizzleObjectRef, drizzleTableKey } from './object-ref.js';
25
25
  import type {
26
26
  DrizzleConnectionFieldOptions,
27
27
  DrizzleConnectionShape,
@@ -35,7 +35,7 @@ import type {
35
35
  drizzleTableName,
36
36
  ShapeFromConnection,
37
37
  ShapeFromIdColumns,
38
- } from './types';
38
+ } from './types.js';
39
39
 
40
40
  declare global {
41
41
  export namespace PothosSchemaTypes {
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
- import './global-types';
2
- import './field-builder';
3
- import './schema-builder';
1
+ import './global-types.js';
2
+ import './field-builder.js';
3
+ import './schema-builder.js';
4
4
  import SchemaBuilder, {
5
5
  BasePlugin,
6
6
  type PothosOutputFieldConfig,
@@ -9,14 +9,14 @@ import SchemaBuilder, {
9
9
  type SchemaTypes,
10
10
  } from '@pothos/core';
11
11
  import type { GraphQLFieldResolver } from 'graphql';
12
- import type { ModelLoader } from './model-loader';
13
- import { getLoaderMapping, setLoaderMappings } from './utils/loader-map';
14
-
15
- export { drizzleConnectionHelpers } from './connection-helpers';
16
- export { DrizzleObjectFieldBuilder } from './drizzle-field-builder';
17
- export * from './types';
18
- export { drizzleTableName } from './types';
19
- export { drizzleClientCache } from './utils/config';
12
+ import type { ModelLoader } from './model-loader.js';
13
+ import { getLoaderMapping, setLoaderMappings } from './utils/loader-map.js';
14
+
15
+ export { drizzleConnectionHelpers } from './connection-helpers.js';
16
+ export { DrizzleObjectFieldBuilder } from './drizzle-field-builder.js';
17
+ export * from './types.js';
18
+ export { drizzleTableName } from './types.js';
19
+ export { drizzleClientCache } from './utils/config.js';
20
20
 
21
21
  const pluginName = 'drizzle';
22
22
 
@@ -1,6 +1,6 @@
1
1
  import { InterfaceRef, type SchemaTypes } from '@pothos/core';
2
- import type { DrizzleNodeRef } from './node-ref';
3
- import { type DrizzleObjectRef, drizzleTableKey } from './object-ref';
2
+ import type { DrizzleNodeRef } from './node-ref.js';
3
+ import { type DrizzleObjectRef, drizzleTableKey } from './object-ref.js';
4
4
 
5
5
  export type DrizzleRef<
6
6
  Types extends SchemaTypes,
@@ -9,16 +9,16 @@ import {
9
9
  type TableRelationalConfig,
10
10
  } from 'drizzle-orm';
11
11
  import type { GraphQLResolveInfo } from 'graphql';
12
- import { getClient, getSchemaConfig, type PothosDrizzleSchemaConfig } from './utils/config';
13
- import { cacheKey, setLoaderMappings } from './utils/loader-map';
14
- import { selectionStateFromInfo, stateFromInfo } from './utils/map-query';
12
+ import { getClient, getSchemaConfig, type PothosDrizzleSchemaConfig } from './utils/config.js';
13
+ import { cacheKey, setLoaderMappings } from './utils/loader-map.js';
14
+ import { selectionStateFromInfo, stateFromInfo } from './utils/map-query.js';
15
15
  import {
16
16
  mergeSelection,
17
17
  type SelectionMap,
18
18
  type SelectionState,
19
19
  selectionCompatible,
20
20
  selectionToQuery,
21
- } from './utils/selections';
21
+ } from './utils/selections.js';
22
22
 
23
23
  interface ResolvablePromise<T> {
24
24
  promise: Promise<T>;
package/src/node-ref.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { SchemaTypes } from '@pothos/core';
2
- import { DrizzleObjectRef } from './object-ref';
2
+ import { DrizzleObjectRef } from './object-ref.js';
3
3
 
4
4
  export const relayIDShapeKey = Symbol.for('Pothos.relayIDShapeKey');
5
5
 
package/src/object-ref.ts CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  type SchemaTypes,
6
6
  typeBrandKey,
7
7
  } from '@pothos/core';
8
- import type { WithBrand } from './types';
8
+ import type { WithBrand } from './types.js';
9
9
 
10
10
  export const drizzleTableKey = Symbol.for('Pothos.drizzleTableKey');
11
11
 
@@ -10,15 +10,15 @@ import SchemaBuilder, {
10
10
  } from '@pothos/core';
11
11
  import type { Column } from 'drizzle-orm';
12
12
  import type { GraphQLResolveInfo } from 'graphql';
13
- import { DrizzleObjectFieldBuilder } from './drizzle-field-builder';
14
- import { DrizzleInterfaceRef } from './interface-ref';
15
- import { ModelLoader } from './model-loader';
16
- import { DrizzleNodeRef } from './node-ref';
17
- import { DrizzleObjectRef } from './object-ref';
18
- import type { DrizzleNodeOptions } from './types';
19
- import { getSchemaConfig } from './utils/config';
20
- import { getIDParser, getIDSerializer } from './utils/cursors';
21
- import { getRefFromModel } from './utils/refs';
13
+ import { DrizzleObjectFieldBuilder } from './drizzle-field-builder.js';
14
+ import { DrizzleInterfaceRef } from './interface-ref.js';
15
+ import { ModelLoader } from './model-loader.js';
16
+ import { DrizzleNodeRef } from './node-ref.js';
17
+ import { DrizzleObjectRef } from './object-ref.js';
18
+ import type { DrizzleNodeOptions } from './types.js';
19
+ import { getSchemaConfig } from './utils/config.js';
20
+ import { getIDParser, getIDSerializer } from './utils/cursors.js';
21
+ import { getRefFromModel } from './utils/refs.js';
22
22
 
23
23
  const schemaBuilderProto = SchemaBuilder.prototype as PothosSchemaTypes.SchemaBuilder<SchemaTypes>;
24
24
 
package/src/types.ts CHANGED
@@ -39,10 +39,10 @@ import type {
39
39
  TableRelationalConfig,
40
40
  } from 'drizzle-orm';
41
41
  import type { FieldNode, GraphQLResolveInfo } from 'graphql';
42
- import type { DrizzleObjectFieldBuilder } from './drizzle-field-builder';
43
- import type { DrizzleRef } from './interface-ref';
44
- import type { IndirectInclude } from './utils/map-query';
45
- import type { SelectionMap } from './utils/selections';
42
+ import type { DrizzleObjectFieldBuilder } from './drizzle-field-builder.js';
43
+ import type { DrizzleRef } from './interface-ref.js';
44
+ import type { IndirectInclude } from './utils/map-query.js';
45
+ import type { SelectionMap } from './utils/selections.js';
46
46
 
47
47
  export interface FieldPathInfo {
48
48
  field: string;
@@ -736,4 +736,4 @@ export interface DrizzleGraphQLInputExtensions {
736
736
  inputType: 'insert' | 'filters' | 'orderBy' | 'update';
737
737
  }
738
738
 
739
- export { DrizzleObjectRef } from './object-ref';
739
+ export { DrizzleObjectRef } from './object-ref.js';
@@ -1,6 +1,6 @@
1
1
  import { createContextCache, type SchemaTypes } from '@pothos/core';
2
2
  import { type AnyRelations, type Column, getColumns, isTable, type Table } from 'drizzle-orm';
3
- import type { DrizzleClient } from '../types';
3
+ import type { DrizzleClient } from '../types.js';
4
4
 
5
5
  export interface PothosDrizzleSchemaConfig {
6
6
  skipDeferredFragments: boolean;
@@ -14,10 +14,10 @@ import {
14
14
  type TableRelationalConfig,
15
15
  } from 'drizzle-orm';
16
16
  import type { GraphQLResolveInfo } from 'graphql';
17
- import type { ConnectionOrderBy, QueryForDrizzleConnection } from '../types';
18
- import type { PothosDrizzleSchemaConfig } from './config';
19
- import { queryFromInfo } from './map-query';
20
- import type { SelectionMap } from './selections';
17
+ import type { ConnectionOrderBy, QueryForDrizzleConnection } from '../types.js';
18
+ import type { PothosDrizzleSchemaConfig } from './config.js';
19
+ import { queryFromInfo } from './map-query.js';
20
+ import { omitUndefinedKeys, type SelectionMap } from './selections.js';
21
21
 
22
22
  const DEFAULT_MAX_SIZE = 100;
23
23
  const DEFAULT_SIZE = 20;
@@ -446,13 +446,13 @@ export function drizzleCursorConnectionQuery({
446
446
  whereClauses.push(parts.length > 1 ? { OR: parts } : parts[0]);
447
447
  }
448
448
 
449
- return {
449
+ return omitUndefinedKeys({
450
450
  cursorColumns: parsedOrderBy.columns,
451
451
  columns,
452
452
  orderBy: parsedOrderBy.orderBy,
453
453
  limit,
454
454
  where: whereClauses.length > 1 ? { AND: whereClauses } : whereClauses[0],
455
- };
455
+ });
456
456
  }
457
457
 
458
458
  export function wrapConnectionResult<T extends {}>(
@@ -540,7 +540,7 @@ export async function resolveDrizzleCursorConnection<T extends {}>(
540
540
  query = queryFromInfo({
541
541
  context: options.ctx,
542
542
  info,
543
- select: {
543
+ select: omitUndefinedKeys({
544
544
  ...connectionQuery,
545
545
  columns: {
546
546
  ...q.columns,
@@ -552,7 +552,7 @@ export async function resolveDrizzleCursorConnection<T extends {}>(
552
552
  AND: [q.where, connectionQuery.where],
553
553
  }
554
554
  : q.where || connectionQuery.where,
555
- } as never,
555
+ }) as never,
556
556
  paths: [['nodes'], ['edges', 'node']],
557
557
  typeName,
558
558
  config,
@@ -20,9 +20,9 @@ import {
20
20
  Kind,
21
21
  type SelectionSetNode,
22
22
  } from 'graphql';
23
- import type { DrizzleFieldSelection, FieldPathInfo, PathInfo } from '../types';
24
- import type { PothosDrizzleSchemaConfig } from './config';
25
- import { type LoaderMappings, setLoaderMappings } from './loader-map';
23
+ import type { DrizzleFieldSelection, FieldPathInfo, PathInfo } from '../types.js';
24
+ import type { PothosDrizzleSchemaConfig } from './config.js';
25
+ import { type LoaderMappings, setLoaderMappings } from './loader-map.js';
26
26
  import {
27
27
  createState,
28
28
  mergeSelection,
@@ -30,8 +30,8 @@ import {
30
30
  type SelectionState,
31
31
  selectionCompatible,
32
32
  selectionToQuery,
33
- } from './selections';
34
- import { wrapWithUsageCheck } from './usage';
33
+ } from './selections.js';
34
+ import { wrapWithUsageCheck } from './usage.js';
35
35
 
36
36
  export interface IndirectInclude {
37
37
  getType: () => string;
package/src/utils/refs.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PothosSchemaError, type SchemaTypes } from '@pothos/core';
2
- import { DrizzleInterfaceRef, type DrizzleRef } from '../interface-ref';
3
- import { DrizzleObjectRef } from '../object-ref';
2
+ import { DrizzleInterfaceRef, type DrizzleRef } from '../interface-ref.js';
3
+ import { DrizzleObjectRef } from '../object-ref.js';
4
4
 
5
5
  export const refMap = new WeakMap<object, Map<string, DrizzleRef<never>>>();
6
6
 
@@ -1,8 +1,8 @@
1
1
  import { PothosValidationError } from '@pothos/core';
2
2
  import type { DBQueryConfig, TableRelationalConfig } from 'drizzle-orm';
3
- import type { PothosDrizzleSchemaConfig } from './config';
4
- import { deepEqual } from './deep-equal';
5
- import type { LoaderMappings } from './loader-map';
3
+ import type { PothosDrizzleSchemaConfig } from './config.js';
4
+ import { deepEqual } from './deep-equal.js';
5
+ import type { LoaderMappings } from './loader-map.js';
6
6
 
7
7
  export interface SelectionState {
8
8
  table: TableRelationalConfig;
@@ -19,6 +19,13 @@ export interface SelectionState {
19
19
 
20
20
  export type SelectionMap = DBQueryConfig<'one'>;
21
21
 
22
+ export function omitUndefinedKeys<T extends object>(query: T): T {
23
+ const entries = Object.entries(query);
24
+ const defined = entries.filter(([, value]) => value !== undefined);
25
+
26
+ return defined.length === entries.length ? query : (Object.fromEntries(defined) as T);
27
+ }
28
+
22
29
  export function selectionCompatible(
23
30
  state: SelectionState,
24
31
  selectionMap: SelectionMap | boolean,
@@ -53,7 +60,7 @@ export function selectionCompatible(
53
60
  return false;
54
61
  }
55
62
 
56
- return ignoreQuery || deepEqual(state.query, query);
63
+ return ignoreQuery || deepEqual(state.query, omitUndefinedKeys(query));
57
64
  }
58
65
 
59
66
  export function stateCompatible(
@@ -134,8 +141,9 @@ export function mergeSelection(
134
141
  }
135
142
  }
136
143
 
137
- if (Object.keys(query).length > 0) {
138
- state.query = query;
144
+ const normalizedQuery = omitUndefinedKeys(query);
145
+ if (Object.keys(normalizedQuery).length > 0) {
146
+ state.query = normalizedQuery;
139
147
  }
140
148
 
141
149
  if (extras) {
@@ -178,7 +186,7 @@ export function selectionToQuery(
178
186
  state: SelectionState,
179
187
  ): SelectionMap {
180
188
  const query: SelectionMap & { extras: Record<string, unknown> } = {
181
- ...state.query,
189
+ ...omitUndefinedKeys(state.query),
182
190
  columns: undefined,
183
191
  with: {},
184
192
  extras: {},