@pothos/plugin-drizzle 0.18.1 → 0.19.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 +345 -0
- package/README.md +784 -221
- package/dts/connection-helpers.d.ts +18 -8
- package/dts/connection-helpers.d.ts.map +1 -1
- package/dts/drizzle-field-builder.d.ts +4 -11
- package/dts/drizzle-field-builder.d.ts.map +1 -1
- package/dts/global-types.d.ts.map +1 -1
- package/dts/index.d.ts.map +1 -1
- package/dts/model-loader.d.ts +18 -17
- package/dts/model-loader.d.ts.map +1 -1
- package/dts/types.d.ts +80 -20
- package/dts/types.d.ts.map +1 -1
- package/dts/utils/adapter.d.ts +39 -0
- package/dts/utils/adapter.d.ts.map +1 -0
- package/dts/utils/await-selections.d.ts +12 -0
- package/dts/utils/await-selections.d.ts.map +1 -0
- package/dts/utils/config.d.ts +23 -3
- package/dts/utils/config.d.ts.map +1 -1
- package/dts/utils/cursors.d.ts +6 -6
- package/dts/utils/cursors.d.ts.map +1 -1
- package/dts/utils/map-query.d.ts +22 -21
- package/dts/utils/map-query.d.ts.map +1 -1
- package/dts/utils/path-info.d.ts +13 -0
- package/dts/utils/path-info.d.ts.map +1 -0
- package/dts/utils/relation-filter.d.ts +48 -0
- package/dts/utils/relation-filter.d.ts.map +1 -0
- package/dts/utils/selections.d.ts +2 -21
- package/dts/utils/selections.d.ts.map +1 -1
- package/esm/connection-helpers.d.ts +18 -8
- package/esm/connection-helpers.d.ts.map +1 -1
- package/esm/connection-helpers.js +52 -19
- package/esm/connection-helpers.js.map +1 -1
- package/esm/drizzle-field-builder.d.ts +4 -11
- package/esm/drizzle-field-builder.d.ts.map +1 -1
- package/esm/drizzle-field-builder.js +138 -96
- package/esm/drizzle-field-builder.js.map +1 -1
- package/esm/field-builder.js +61 -47
- package/esm/field-builder.js.map +1 -1
- package/esm/global-types.d.ts.map +1 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +37 -61
- package/esm/index.js.map +1 -1
- package/esm/model-loader.d.ts +18 -17
- package/esm/model-loader.d.ts.map +1 -1
- package/esm/model-loader.js +76 -45
- package/esm/model-loader.js.map +1 -1
- package/esm/schema-builder.js +40 -149
- package/esm/schema-builder.js.map +1 -1
- package/esm/types.d.ts +80 -20
- package/esm/types.d.ts.map +1 -1
- package/esm/types.js.map +1 -1
- package/esm/utils/adapter.d.ts +39 -0
- package/esm/utils/adapter.d.ts.map +1 -0
- package/esm/utils/adapter.js +137 -0
- package/esm/utils/adapter.js.map +1 -0
- package/esm/utils/await-selections.d.ts +12 -0
- package/esm/utils/await-selections.d.ts.map +1 -0
- package/esm/utils/await-selections.js +19 -0
- package/esm/utils/await-selections.js.map +1 -0
- package/esm/utils/config.d.ts +23 -3
- package/esm/utils/config.d.ts.map +1 -1
- package/esm/utils/config.js +1 -4
- package/esm/utils/config.js.map +1 -1
- package/esm/utils/cursors.d.ts +6 -6
- package/esm/utils/cursors.d.ts.map +1 -1
- package/esm/utils/cursors.js +55 -90
- package/esm/utils/cursors.js.map +1 -1
- package/esm/utils/map-query.d.ts +22 -21
- package/esm/utils/map-query.d.ts.map +1 -1
- package/esm/utils/map-query.js +40 -354
- package/esm/utils/map-query.js.map +1 -1
- package/esm/utils/path-info.d.ts +13 -0
- package/esm/utils/path-info.d.ts.map +1 -0
- package/esm/utils/path-info.js +37 -0
- package/esm/utils/path-info.js.map +1 -0
- package/esm/utils/relation-filter.d.ts +48 -0
- package/esm/utils/relation-filter.d.ts.map +1 -0
- package/esm/utils/relation-filter.js +92 -0
- package/esm/utils/relation-filter.js.map +1 -0
- package/esm/utils/selections.d.ts +2 -21
- package/esm/utils/selections.d.ts.map +1 -1
- package/esm/utils/selections.js +1 -133
- package/esm/utils/selections.js.map +1 -1
- package/lib/connection-helpers.js +51 -18
- package/lib/connection-helpers.js.map +1 -1
- package/lib/drizzle-field-builder.js +136 -94
- package/lib/drizzle-field-builder.js.map +1 -1
- package/lib/field-builder.js +58 -44
- package/lib/field-builder.js.map +1 -1
- package/lib/index.js +36 -60
- package/lib/index.js.map +1 -1
- package/lib/model-loader.js +76 -45
- package/lib/model-loader.js.map +1 -1
- package/lib/schema-builder.js +40 -149
- package/lib/schema-builder.js.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utils/adapter.js +147 -0
- package/lib/utils/adapter.js.map +1 -0
- package/lib/utils/await-selections.js +20 -0
- package/lib/utils/await-selections.js.map +1 -0
- package/lib/utils/config.js +1 -4
- package/lib/utils/config.js.map +1 -1
- package/lib/utils/cursors.js +47 -88
- package/lib/utils/cursors.js.map +1 -1
- package/lib/utils/map-query.js +28 -359
- package/lib/utils/map-query.js.map +1 -1
- package/lib/utils/path-info.js +39 -0
- package/lib/utils/path-info.js.map +1 -0
- package/lib/utils/relation-filter.js +91 -0
- package/lib/utils/relation-filter.js.map +1 -0
- package/lib/utils/selections.js +3 -158
- package/lib/utils/selections.js.map +1 -1
- package/package.json +8 -6
- package/src/connection-helpers.ts +167 -53
- package/src/drizzle-field-builder.ts +296 -176
- package/src/field-builder.ts +110 -77
- package/src/global-types.ts +0 -32
- package/src/index.ts +42 -68
- package/src/model-loader.ts +110 -71
- package/src/schema-builder.ts +76 -169
- package/src/types.ts +175 -44
- package/src/utils/adapter.ts +197 -0
- package/src/utils/await-selections.ts +31 -0
- package/src/utils/config.ts +1 -5
- package/src/utils/cursors.ts +53 -81
- package/src/utils/map-query.ts +51 -734
- package/src/utils/path-info.ts +40 -0
- package/src/utils/relation-filter.ts +185 -0
- package/src/utils/selections.ts +2 -207
- package/dts/utils/deep-equal.d.ts +0 -2
- package/dts/utils/deep-equal.d.ts.map +0 -1
- package/dts/utils/drizzle-graphql.d.ts +0 -2
- package/dts/utils/drizzle-graphql.d.ts.map +0 -1
- package/dts/utils/loader-map.d.ts +0 -11
- package/dts/utils/loader-map.d.ts.map +0 -1
- package/dts/utils/usage.d.ts +0 -5
- package/dts/utils/usage.d.ts.map +0 -1
- package/esm/utils/deep-equal.d.ts +0 -2
- package/esm/utils/deep-equal.d.ts.map +0 -1
- package/esm/utils/deep-equal.js +0 -45
- package/esm/utils/deep-equal.js.map +0 -1
- package/esm/utils/drizzle-graphql.d.ts +0 -2
- package/esm/utils/drizzle-graphql.d.ts.map +0 -1
- package/esm/utils/drizzle-graphql.js +0 -232
- package/esm/utils/drizzle-graphql.js.map +0 -1
- package/esm/utils/loader-map.d.ts +0 -11
- package/esm/utils/loader-map.d.ts.map +0 -1
- package/esm/utils/loader-map.js +0 -35
- package/esm/utils/loader-map.js.map +0 -1
- package/esm/utils/usage.d.ts +0 -5
- package/esm/utils/usage.d.ts.map +0 -1
- package/esm/utils/usage.js +0 -59
- package/esm/utils/usage.js.map +0 -1
- package/lib/utils/deep-equal.js +0 -55
- package/lib/utils/deep-equal.js.map +0 -1
- package/lib/utils/drizzle-graphql.js +0 -236
- package/lib/utils/drizzle-graphql.js.map +0 -1
- package/lib/utils/loader-map.js +0 -56
- package/lib/utils/loader-map.js.map +0 -1
- package/lib/utils/usage.js +0 -83
- package/lib/utils/usage.js.map +0 -1
- package/src/utils/deep-equal.ts +0 -57
- package/src/utils/drizzle-graphql.ts +0 -274
- package/src/utils/loader-map.ts +0 -49
- package/src/utils/usage.ts +0 -62
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type Node, NodeAdapter, type Plan, type PlayedPlan, type QueryVisitor, type SelectFn } from '@pothos/selection-mapper';
|
|
2
|
+
import type { TableRelationalConfig } from 'drizzle-orm';
|
|
3
|
+
import type { GraphQLField, GraphQLNamedType } from 'graphql';
|
|
4
|
+
import type { PothosDrizzleSchemaConfig } from './config.js';
|
|
5
|
+
import { type SelectionMap } from './selections.js';
|
|
6
|
+
export type DrizzleNode = Node<TableRelationalConfig>;
|
|
7
|
+
export type DrizzlePlan = Plan<TableRelationalConfig, SelectionMap>;
|
|
8
|
+
export type DrizzlePlayedPlan = PlayedPlan<TableRelationalConfig, SelectionMap>;
|
|
9
|
+
type DrizzleVisitor = QueryVisitor<TableRelationalConfig, SelectionMap>;
|
|
10
|
+
/**
|
|
11
|
+
* How drizzle selections (`DBQueryConfig`: `columns`, `with`, `extras` and query arguments) read
|
|
12
|
+
* onto the shared query tree, and how a node is written back. A node whose columns are `null`
|
|
13
|
+
* selects every column; a named-column node always adds the table's primary key so rows can be
|
|
14
|
+
* matched back to their parent.
|
|
15
|
+
*
|
|
16
|
+
* The merge, compare and conflict rules are `NodeAdapter`'s: this is the schema side, the key
|
|
17
|
+
* loop and `toQuery`. The schema config every one of them needs is the adapter's own state.
|
|
18
|
+
*/
|
|
19
|
+
export declare class DrizzleAdapter extends NodeAdapter<TableRelationalConfig, SelectionMap> {
|
|
20
|
+
private readonly config;
|
|
21
|
+
skipDeferredFragments: boolean;
|
|
22
|
+
private readonly fieldSelections;
|
|
23
|
+
constructor(config: PothosDrizzleSchemaConfig);
|
|
24
|
+
modelFor(type: GraphQLNamedType): TableRelationalConfig | undefined;
|
|
25
|
+
typeSelection(type: GraphQLNamedType): SelectionMap | undefined;
|
|
26
|
+
fieldSelection(field: GraphQLField<unknown, unknown>): SelectFn<SelectionMap> | import("drizzle-orm").DBQueryConfig<"one"> | undefined;
|
|
27
|
+
visitQuery({ columns, with: withSelection, extras, ...args }: SelectionMap, model: TableRelationalConfig, visit: DrizzleVisitor): void;
|
|
28
|
+
/**
|
|
29
|
+
* Drizzle's `extras` are functions, compared by identity: the inherited deep-equal would let
|
|
30
|
+
* two different functions computing the same shape merge.
|
|
31
|
+
*/
|
|
32
|
+
computedConflicts(computed: ReadonlyMap<string, unknown>, name: string, value: unknown): boolean;
|
|
33
|
+
toQuery(node: DrizzleNode): SelectionMap;
|
|
34
|
+
/** The keys of a `with` map, resolved to the tables they target. */
|
|
35
|
+
private readRelations;
|
|
36
|
+
}
|
|
37
|
+
export declare const drizzleAdapter: import("@pothos/core").ContextCache<DrizzleAdapter, PothosDrizzleSchemaConfig, []>;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=adapter.d.ts.map
|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E,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,EAAE,YAAY,EAC/D,KAAK,EAAE,qBAAqB,EAC5B,KAAK,EAAE,cAAc,QAqBtB;IAED;;;OAGG;IACM,iBAAiB,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,WAE9F;IAED,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,YAAY,CA6BvC;IAED,oEAAoE;IACpE,OAAO,CAAC,aAAa;CAyBtB;AAED,eAAO,MAAM,cAAc,oFAE1B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The guard behind `awaitSelections`. A query is only built asynchronously when a selection
|
|
3
|
+
* beneath the field is async, which the call site cannot see: what it plans is the rest of the
|
|
4
|
+
* document. Rather than hand back a promise where the declared type says there is none — which
|
|
5
|
+
* spreads into a drizzle call as one unusable key, with no type error — the promise is refused
|
|
6
|
+
* unless the caller asked for it.
|
|
7
|
+
*
|
|
8
|
+
* The refused promise is left handled, so a plan that also rejects does not report an unhandled
|
|
9
|
+
* rejection on the way out.
|
|
10
|
+
*/
|
|
11
|
+
export declare function checkAwaitSelections<T>(value: T, awaitSelections: boolean | undefined, caller: string, subject: string): T;
|
|
12
|
+
//# sourceMappingURL=await-selections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"await-selections.d.ts","sourceRoot":"","sources":["../../src/utils/await-selections.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,KAAK,EAAE,CAAC,EACR,eAAe,EAAE,OAAO,GAAG,SAAS,EACpC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GACd,CAAC,CAaH"}
|
package/dts/utils/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SchemaTypes } from '@pothos/core';
|
|
2
|
-
import { type AnyRelations, type Column } from 'drizzle-orm';
|
|
2
|
+
import { type AnyRelations, type Column, type Table } from 'drizzle-orm';
|
|
3
3
|
export interface PothosDrizzleSchemaConfig {
|
|
4
4
|
skipDeferredFragments: boolean;
|
|
5
5
|
relations: AnyRelations;
|
|
@@ -13,15 +13,35 @@ export declare const drizzleClientCache: import("@pothos/core").ContextCache<imp
|
|
|
13
13
|
readonly _: {
|
|
14
14
|
readonly relations: AnyRelations;
|
|
15
15
|
};
|
|
16
|
-
query: {
|
|
16
|
+
query: Record<string, {
|
|
17
|
+
findMany: (config: never) => PromiseLike<Record<string, unknown>[]>;
|
|
18
|
+
}>;
|
|
17
19
|
$count: (source: import("drizzle-orm").SQL<unknown> | import("drizzle-orm").SQLWrapper<unknown> | import("drizzle-orm").SchemaEntry, filter?: import("drizzle-orm").SQL) => import("drizzle-orm").SQL<number>;
|
|
20
|
+
select: (fields: Record<string, import("drizzle-orm").SQL>) => {
|
|
21
|
+
from(table: Table<any>): {
|
|
22
|
+
innerJoin(table: Table<any>, on: import("drizzle-orm").SQL): {
|
|
23
|
+
where: (filter?: import("drizzle-orm").SQL) => import("drizzle-orm").SQLWrapper;
|
|
24
|
+
};
|
|
25
|
+
where: (filter?: import("drizzle-orm").SQL) => import("drizzle-orm").SQLWrapper;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
18
28
|
}, object, []>, PothosSchemaTypes.SchemaBuilder<SchemaTypes>, []>;
|
|
19
29
|
export declare function getSchemaConfig<Types extends SchemaTypes>(builder: PothosSchemaTypes.SchemaBuilder<Types>): PothosDrizzleSchemaConfig;
|
|
20
30
|
export declare function getClient<Types extends SchemaTypes>(builder: PothosSchemaTypes.SchemaBuilder<Types>, context: object): {
|
|
21
31
|
readonly _: {
|
|
22
32
|
readonly relations: AnyRelations;
|
|
23
33
|
};
|
|
24
|
-
query: {
|
|
34
|
+
query: Record<string, {
|
|
35
|
+
findMany: (config: never) => PromiseLike<Record<string, unknown>[]>;
|
|
36
|
+
}>;
|
|
25
37
|
$count: (source: import("drizzle-orm").SQL<unknown> | import("drizzle-orm").SQLWrapper<unknown> | import("drizzle-orm").SchemaEntry, filter?: import("drizzle-orm").SQL) => import("drizzle-orm").SQL<number>;
|
|
38
|
+
select: (fields: Record<string, import("drizzle-orm").SQL>) => {
|
|
39
|
+
from(table: Table<any>): {
|
|
40
|
+
innerJoin(table: Table<any>, on: import("drizzle-orm").SQL): {
|
|
41
|
+
where: (filter?: import("drizzle-orm").SQL) => import("drizzle-orm").SQLWrapper;
|
|
42
|
+
};
|
|
43
|
+
where: (filter?: import("drizzle-orm").SQL) => import("drizzle-orm").SQLWrapper;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
26
46
|
};
|
|
27
47
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,MAAM,EAAuB,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAG9F,MAAM,WAAW,yBAAyB;IACxC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,SAAS,EAAE,YAAY,CAAC;IACxB,cAAc,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,EAAE,GAAG,IAAI,CAAC;IACvD,cAAc,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,EAAE,GAAG,IAAI,CAAC;IACvD,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;IAC/C,oBAAoB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,EAAE,EAAE,CAAC;IACxD,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CAC5C;AA2JD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;iEAU9B,CAAC;AAEF,wBAAgB,eAAe,CAAC,KAAK,SAAS,WAAW,EACvD,OAAO,EAAE,iBAAiB,CAAC,aAAa,CAAC,KAAK,CAAC,6BAGhD;AAED,wBAAgB,SAAS,CAAC,KAAK,SAAS,WAAW,EACjD,OAAO,EAAE,iBAAiB,CAAC,aAAa,CAAC,KAAK,CAAC,EAC/C,OAAO,EAAE,MAAM;;;;;;;;;;;;;;;;EAGhB"}
|
package/dts/utils/cursors.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { type MaybePromise, type SchemaTypes } from '@pothos/core';
|
|
1
|
+
import { encodeCursorChunk, type MaybePromise, type SchemaTypes } from '@pothos/core';
|
|
2
2
|
import { type Column, type SQL, type Table, type TableRelationalConfig } from 'drizzle-orm';
|
|
3
|
-
import type { GraphQLResolveInfo } from 'graphql';
|
|
4
3
|
import type { ConnectionOrderBy, QueryForDrizzleConnection } from '../types.js';
|
|
4
|
+
import type { DrizzlePlan } from './adapter.js';
|
|
5
5
|
import type { PothosDrizzleSchemaConfig } from './config.js';
|
|
6
6
|
import { type SelectionMap } from './selections.js';
|
|
7
|
-
export declare
|
|
7
|
+
export declare const formatCursorChunk: typeof encodeCursorChunk;
|
|
8
8
|
export declare function formatDrizzleCursor(record: Record<string, unknown>, fields: Column[], config: PothosDrizzleSchemaConfig): string;
|
|
9
9
|
export declare function formatIDChunk(value: unknown): string;
|
|
10
10
|
export declare function getIDSerializer(fields: Column[], config: PothosDrizzleSchemaConfig): (value: Record<string, unknown>) => string;
|
|
11
11
|
export type CursorField = Column | string;
|
|
12
12
|
export declare function cursorFieldKey(field: CursorField, config: PothosDrizzleSchemaConfig): string;
|
|
13
|
-
export declare function getColumnSerializer(fields: readonly CursorField[], config: PothosDrizzleSchemaConfig): (value: Record<string, unknown>) => string
|
|
13
|
+
export declare function getColumnSerializer(fields: readonly CursorField[], config: PothosDrizzleSchemaConfig): (value: Record<string, unknown>) => string;
|
|
14
14
|
export declare function getCursorFormatter(fields: readonly CursorField[], config: PothosDrizzleSchemaConfig): (value: Record<string, unknown>) => string;
|
|
15
15
|
export declare function parseDrizzleCursor(cursor: unknown): unknown;
|
|
16
16
|
export declare function parseSerializedDrizzleColumn(value: unknown): unknown;
|
|
17
17
|
export declare function parseSerializedIDColumn(id: string, field: Column): unknown;
|
|
18
|
-
export declare function getIDParser(fields: readonly Column[]): (value: string) => Record<string, unknown>;
|
|
18
|
+
export declare function getIDParser(fields: readonly Column[], config: PothosDrizzleSchemaConfig): (value: string) => Record<string, unknown>;
|
|
19
19
|
export declare function getColumnParser(fields: readonly Column[]): (value: unknown) => Record<string, unknown>;
|
|
20
20
|
export declare function getCursorParser(keys: readonly string[]): (cursor: unknown) => Record<string, unknown>;
|
|
21
21
|
export interface DrizzleCursorConnectionQueryOptions {
|
|
@@ -54,7 +54,7 @@ export declare function wrapConnectionResult<T extends {}>(results: readonly T[]
|
|
|
54
54
|
hasNextPage: boolean;
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
|
-
export declare function resolveDrizzleCursorConnection<T extends {}>(tableName: string,
|
|
57
|
+
export declare function resolveDrizzleCursorConnection<T extends {}>(tableName: string, plan: DrizzlePlan | undefined, config: PothosDrizzleSchemaConfig, options: Omit<DrizzleCursorConnectionQueryOptions, 'orderBy' | 'config' | 'table'> & {
|
|
58
58
|
totalCount?: () => MaybePromise<number>;
|
|
59
59
|
}, resolve: (queryFn: (query: QueryForDrizzleConnection<SchemaTypes, TableRelationalConfig>) => SelectionMap) => MaybePromise<readonly T[]>, parent: unknown): Promise<{
|
|
60
60
|
parent: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cursors.d.ts","sourceRoot":"","sources":["../../src/utils/cursors.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"cursors.d.ts","sourceRoot":"","sources":["../../src/utils/cursors.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAGjB,KAAK,YAAY,EAEjB,KAAK,WAAW,EAEjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAEL,KAAK,MAAM,EAQX,KAAK,GAAG,EAER,KAAK,KAAK,EACV,KAAK,qBAAqB,EAC3B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAMvE,eAAO,MAAM,iBAAiB,0BAAoB,CAAC;AAEnD,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,EAAE,MAAM,EAAE,EAChB,MAAM,EAAE,yBAAyB,UAGlC;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,UAa3C;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,yBAAyB,WAKlE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAOvC;AAKD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1C,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,yBAAyB,UAEnF;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,WAAW,EAAE,EAC9B,MAAM,EAAE,yBAAyB,WAMlB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAS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BAAqB,CAAC,KAAK,YAAY,KAC5F,YAAY,CAAC,SAAS,CAAC,EAAE,CAAC,EAC/B,MAAM,EAAE,OAAO;;;gCA9Dc,YAAY,CAAC,MAAM,CAAC;;gBAcvB,MAAM;cAAQ,OAAO;;;qBAEtB,MAAM,GAAG,IAAI;mBACf,MAAM,GAAG,IAAI;;;;GAkHrC"}
|
package/dts/utils/map-query.d.ts
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type PathSegment } from '@pothos/selection-mapper';
|
|
2
|
+
import type { GraphQLResolveInfo } from 'graphql';
|
|
3
|
+
import { type DrizzlePlan } from './adapter.js';
|
|
2
4
|
import type { PothosDrizzleSchemaConfig } from './config.js';
|
|
3
|
-
import {
|
|
4
|
-
export interface IndirectInclude {
|
|
5
|
-
getType: () => string;
|
|
6
|
-
path?: {
|
|
7
|
-
type?: string;
|
|
8
|
-
name: string;
|
|
9
|
-
}[];
|
|
10
|
-
paths?: {
|
|
11
|
-
type?: string;
|
|
12
|
-
name: string;
|
|
13
|
-
}[][];
|
|
14
|
-
}
|
|
5
|
+
import type { SelectionMap } from './selections.js';
|
|
15
6
|
export interface QueryFromInfoOptions<T extends SelectionMap> {
|
|
16
7
|
config: PothosDrizzleSchemaConfig;
|
|
17
8
|
context: object;
|
|
18
9
|
info: GraphQLResolveInfo;
|
|
19
10
|
typeName?: string;
|
|
20
11
|
select?: T;
|
|
21
|
-
path?:
|
|
22
|
-
paths?:
|
|
23
|
-
withUsageCheck?: boolean;
|
|
12
|
+
path?: PathSegment[];
|
|
13
|
+
paths?: PathSegment[][];
|
|
24
14
|
}
|
|
25
|
-
export declare function queryFromInfo<T extends SelectionMap>({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
15
|
+
export declare function queryFromInfo<T extends SelectionMap>({ config, select, ...options }: QueryFromInfoOptions<T>): T;
|
|
16
|
+
/**
|
|
17
|
+
* The plan for the field `info` resolves (or `typeName`), nothing recorded: a promise while a
|
|
18
|
+
* select beneath the field is async, undefined when `paths` are given and nothing is selected
|
|
19
|
+
* under them. The model loader's, and the first step of a `drizzleField` resolve, whose
|
|
20
|
+
* merges are recorded so the resolver's `query()` selection can come first.
|
|
21
|
+
*/
|
|
22
|
+
export declare function planFromInfo({ config, ...options }: Omit<QueryFromInfoOptions<SelectionMap>, 'select'>): DrizzlePlan | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* The query for a plan `planFromInfo` returned, settled: the caller's `select` first, the walked
|
|
25
|
+
* plan after it, the mappings recorded, and the query serialized. This is how the `query()`
|
|
26
|
+
* builder handed to a `drizzleField` or `drizzleConnection` resolver stays synchronous once a
|
|
27
|
+
* selection beneath the field is async, with the precedence of `queryFromInfo`: a relation the
|
|
28
|
+
* document also plans with other arguments loads on its own.
|
|
29
|
+
*/
|
|
30
|
+
export declare function queryFromPlan<T extends SelectionMap>(plan: DrizzlePlan | undefined, select?: T): T;
|
|
30
31
|
//# sourceMappingURL=map-query.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-query.d.ts","sourceRoot":"","sources":["../../src/utils/map-query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"map-query.d.ts","sourceRoot":"","sources":["../../src/utils/map-query.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAQ,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,KAAK,WAAW,EAAkB,MAAM,cAAc,CAAC;AAChE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,YAAY;IAC1D,MAAM,EAAE,yBAAyB,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,kBAAkB,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,IAAI,CAAC,EAAE,WAAW,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,WAAW,EAAE,EAAE,CAAC;CACzB;AAED,wBAAgB,aAAa,CAAC,CAAC,SAAS,YAAY,EAAE,EACpD,MAAM,EACN,MAAM,EACN,GAAG,OAAO,EACX,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,CAe7B;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,GAAG,OAAO,EACX,EAAE,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,GAAG,WAAW,GAAG,SAAS,CAE9E;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,YAAY,EAClD,IAAI,EAAE,WAAW,GAAG,SAAS,EAC7B,MAAM,CAAC,EAAE,CAAC,GACT,CAAC,CAQH"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Position } from '@pothos/selection-mapper';
|
|
2
|
+
import type { PathInfo } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The public `PathInfo` of a position: `path` as `Type.field` from the field the query was
|
|
5
|
+
* planned for down to the field being planned, and one segment per step with the alias the
|
|
6
|
+
* document used and whether the field is a list.
|
|
7
|
+
*
|
|
8
|
+
* The walker hands out positions, which are links rather than paths; this is the only place the
|
|
9
|
+
* chain is walked, and it is walked only when a `query` callback or a `select` function actually
|
|
10
|
+
* wants one. A field whose query is a plain object never builds either array.
|
|
11
|
+
*/
|
|
12
|
+
export declare function pathInfoFor(position: Position | undefined): PathInfo | undefined;
|
|
13
|
+
//# sourceMappingURL=path-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-info.d.ts","sourceRoot":"","sources":["../../src/utils/path-info.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,KAAK,EAAiB,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE3D;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAqBhF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type Column, type Relation, type SQL, type Table } from 'drizzle-orm';
|
|
2
|
+
import type { DrizzleClient } from '../types.js';
|
|
3
|
+
/** The public client's SQL construction capability. */
|
|
4
|
+
export type RelationQueryBuilder = Pick<DrizzleClient, 'select'>;
|
|
5
|
+
export interface RelationFilter {
|
|
6
|
+
/**
|
|
7
|
+
* A predicate over the target table alone, for the places where only the target table is in
|
|
8
|
+
* scope: a `where` handed to a user `select`, or a count that selects from the target table.
|
|
9
|
+
* SQLite many-to-many relations with a non-null unique target key project identities through
|
|
10
|
+
* Drizzle's join. Other cases use an `exists` over the junction.
|
|
11
|
+
*/
|
|
12
|
+
filter: SQL;
|
|
13
|
+
/**
|
|
14
|
+
* Counts the rows the relation yields, as an expression for the surrounding query to select.
|
|
15
|
+
* A many-to-many relation joins the junction table in, so the count matches the rows the
|
|
16
|
+
* relational query builder returns for the same relation, junction duplicates included.
|
|
17
|
+
*
|
|
18
|
+
* `where` is the predicate the page query was given, and it goes ahead of the relation's own
|
|
19
|
+
* predicate because that is the order the relational query builder combines the two in. The
|
|
20
|
+
* count then repeats the page query's `where` verbatim, minus the limit and keyset clauses.
|
|
21
|
+
*/
|
|
22
|
+
countRows: (where?: SQL) => SQL<number>;
|
|
23
|
+
/**
|
|
24
|
+
* Counts the distinct target rows the relation reaches, for the callers that count a related
|
|
25
|
+
* row once however many junction rows lead to it. `key` identifies a target row, so it has to
|
|
26
|
+
* be a single column the database guarantees is unique and non-null.
|
|
27
|
+
*
|
|
28
|
+
* This counts off the junction rather than counting the target table filtered by `filter`,
|
|
29
|
+
* which says the same thing the long way round: the join reads the junction rows the parent
|
|
30
|
+
* reaches and stops, where the filter reads the same rows and then looks every key it found
|
|
31
|
+
* back up in the target table.
|
|
32
|
+
*/
|
|
33
|
+
countDistinctRows: (key: Column, where?: SQL) => SQL<number>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The parent-to-child SQL for one relation, built by drizzle so the plugin agrees with the
|
|
37
|
+
* relational query builder on what "related" means: `through` (many-to-many), the relation's own
|
|
38
|
+
* `where`, and a reversed relation's inherited `where` all come from drizzle rather than from a
|
|
39
|
+
* join reassembled here out of source and target columns.
|
|
40
|
+
*
|
|
41
|
+
* Both the join and its restrictions come from `relationToSQL`, including when the target is
|
|
42
|
+
* aliased for the identity lookup. No junction columns or comparisons are reconstructed here.
|
|
43
|
+
*
|
|
44
|
+
* `parentTable` is the parent as it appears in the surrounding query, so the aliased table when
|
|
45
|
+
* the query builder aliased it.
|
|
46
|
+
*/
|
|
47
|
+
export declare function buildRelationFilter(client: RelationQueryBuilder, relation: Relation, parentTable: Table, targetKey?: Column[]): RelationFilter;
|
|
48
|
+
//# sourceMappingURL=relation-filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relation-filter.d.ts","sourceRoot":"","sources":["../../src/utils/relation-filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,MAAM,EAOX,KAAK,QAAQ,EAEb,KAAK,GAAG,EAGR,KAAK,KAAK,EACX,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,uDAAuD;AACvD,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;AAEjE,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,MAAM,EAAE,GAAG,CAAC;IACZ;;;;;;;;OAQG;IACH,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC;IACxC;;;;;;;;;OASG;IACH,iBAAiB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC;CAC9D;AAKD;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,oBAAoB,EAC5B,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,KAAK,EAClB,SAAS,CAAC,EAAE,MAAM,EAAE,GACnB,cAAc,CA+ChB"}
|
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
import type { DBQueryConfig
|
|
2
|
-
import type { PothosDrizzleSchemaConfig } from './config.js';
|
|
3
|
-
import type { LoaderMappings } from './loader-map.js';
|
|
4
|
-
export interface SelectionState {
|
|
5
|
-
table: TableRelationalConfig;
|
|
6
|
-
query: object;
|
|
7
|
-
allColumns: boolean;
|
|
8
|
-
columns: Set<string>;
|
|
9
|
-
with: Map<string, SelectionState>;
|
|
10
|
-
extras: Map<string, NonNullable<SelectionMap['extras']>[string]>;
|
|
11
|
-
mappings: LoaderMappings;
|
|
12
|
-
parent?: SelectionState;
|
|
13
|
-
depth: number;
|
|
14
|
-
skipDeferredFragments: boolean;
|
|
15
|
-
}
|
|
1
|
+
import type { DBQueryConfig } from 'drizzle-orm';
|
|
16
2
|
export type SelectionMap = DBQueryConfig<'one'>;
|
|
3
|
+
/** Drops keys holding `undefined`, so `{ where: cond ? filter : undefined }` reads as `{}`. */
|
|
17
4
|
export declare function omitUndefinedKeys<T extends object>(query: T): T;
|
|
18
|
-
export declare function selectionCompatible(state: SelectionState, selectionMap: SelectionMap | boolean, ignoreQuery?: boolean): boolean;
|
|
19
|
-
export declare function stateCompatible(state: SelectionState, newState: SelectionState, ignoreQuery?: boolean): boolean;
|
|
20
|
-
export declare function mergeState(state: SelectionState, newState: SelectionState): void;
|
|
21
|
-
export declare function createState(table: TableRelationalConfig, skipDeferredFragments: boolean, parent?: SelectionState): SelectionState;
|
|
22
|
-
export declare function mergeSelection(config: PothosDrizzleSchemaConfig, state: SelectionState, selection: SelectionMap | boolean): void;
|
|
23
|
-
export declare function selectionToQuery(config: PothosDrizzleSchemaConfig, state: SelectionState): SelectionMap;
|
|
24
5
|
//# sourceMappingURL=selections.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selections.d.ts","sourceRoot":"","sources":["../../src/utils/selections.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"selections.d.ts","sourceRoot":"","sources":["../../src/utils/selections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,MAAM,YAAY,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;AAEhD,+FAA+F;AAC/F,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAK/D"}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type InputFieldMap, type InputShapeFromFields, type MaybeAsyncSelection, type MaybePromise, type SchemaTypes } from '@pothos/core';
|
|
2
|
+
import type { PathSegment } from '@pothos/selection-mapper';
|
|
2
3
|
import type { BuildQueryResult, DBQueryConfig, RelationsFilter, TableRelationalConfig } from 'drizzle-orm';
|
|
3
4
|
import type { GraphQLResolveInfo } from 'graphql';
|
|
4
5
|
import type { DrizzleRef } from './interface-ref.js';
|
|
5
6
|
import type { QueryForDrizzleConnection } from './types.js';
|
|
6
|
-
|
|
7
|
+
import { type SelectionMap } from './utils/selections.js';
|
|
8
|
+
export declare function drizzleConnectionHelpers<Types extends SchemaTypes, Type extends DrizzleRef<Types> | keyof Types['DrizzleRelations'], Selection extends DBQueryConfig<'one', Types['DrizzleRelations'], TableConfig> | true, TableConfig extends TableRelationalConfig = Types['DrizzleRelations'][Type extends DrizzleRef<Types, infer T> ? T : Type], Shape = Type extends DrizzleRef<any, keyof Types['DrizzleRelations'], infer S> ? S : BuildQueryResult<Types['DrizzleRelations'], TableConfig, true>, EdgeShape = true extends Selection ? Shape : BuildQueryResult<Types['DrizzleRelations'], TableConfig, Selection>, NodeShape = EdgeShape, ExtraArgs extends InputFieldMap = {}>(builder: PothosSchemaTypes.SchemaBuilder<Types>, refOrType: Type, { select, resolveNode, query, args: createArgs, maxSize, defaultSize, }?: {
|
|
7
9
|
args?: (t: PothosSchemaTypes.InputFieldBuilder<Types, 'Arg'>) => ExtraArgs;
|
|
8
|
-
select?: (nestedSelection: <T extends true | {}>(selection?: T) => T, args: InputShapeFromFields<ExtraArgs> & PothosSchemaTypes.DefaultConnectionArguments, ctx: Types['Context']) => Selection
|
|
9
|
-
query?: QueryForDrizzleConnection<Types, TableConfig> extends infer QueryConfig ? QueryConfig | ((args: InputShapeFromFields<ExtraArgs>, context: Types['Context']) => QueryConfig) : never;
|
|
10
|
+
select?: (nestedSelection: <T extends true | {}>(selection?: T) => T, args: InputShapeFromFields<ExtraArgs> & PothosSchemaTypes.DefaultConnectionArguments, ctx: Types['Context']) => MaybeAsyncSelection<Types, Selection>;
|
|
11
|
+
query?: QueryForDrizzleConnection<Types, TableConfig> extends infer QueryConfig ? QueryConfig | ((args: InputShapeFromFields<ExtraArgs>, context: Types['Context']) => MaybeAsyncSelection<Types, QueryConfig>) : never;
|
|
10
12
|
defaultSize?: number | ((args: InputShapeFromFields<ExtraArgs> & PothosSchemaTypes.DefaultConnectionArguments, ctx: Types['Context']) => number);
|
|
11
13
|
maxSize?: number | ((args: PothosSchemaTypes.DefaultConnectionArguments, ctx: Types['Context']) => number);
|
|
12
14
|
resolveNode?: (edge: EdgeShape) => NodeShape;
|
|
13
15
|
}): {
|
|
14
16
|
ref: DrizzleRef<Types, Type extends DrizzleRef<Types, infer T> ? T : Type, Shape>;
|
|
15
|
-
resolve: <Parent = undefined>(list: (EdgeShape & {})[], args: InputShapeFromFields<ExtraArgs> & PothosSchemaTypes.DefaultConnectionArguments, ctx: Types['Context'], parent?: Parent) => {
|
|
17
|
+
resolve: <Parent = undefined>(list: (EdgeShape & {})[], args: InputShapeFromFields<ExtraArgs> & PothosSchemaTypes.DefaultConnectionArguments, ctx: Types['Context'], parent?: Parent) => MaybeAsyncSelection<Types, {
|
|
16
18
|
parent: Parent;
|
|
17
19
|
edges: (Omit<EdgeShape, 'cursor' | 'node'> & {
|
|
18
20
|
node: NodeShape;
|
|
@@ -24,14 +26,22 @@ export declare function drizzleConnectionHelpers<Types extends SchemaTypes, Type
|
|
|
24
26
|
hasPreviousPage: boolean;
|
|
25
27
|
hasNextPage: boolean;
|
|
26
28
|
};
|
|
27
|
-
}
|
|
29
|
+
}>;
|
|
28
30
|
select: {};
|
|
29
|
-
getQuery: (args: InputShapeFromFields<ExtraArgs> & PothosSchemaTypes.DefaultConnectionArguments, ctx: Types['Context'], nestedSelectionOrInfo: (
|
|
31
|
+
getQuery: <Await extends boolean = false>(args: InputShapeFromFields<ExtraArgs> & PothosSchemaTypes.DefaultConnectionArguments, ctx: Types['Context'], nestedSelectionOrInfo: ((selection?: SelectionMap | true, path?: PathSegment[]) => unknown) | GraphQLResolveInfo, options?: {
|
|
32
|
+
/** Whether the caller will await the query. */
|
|
33
|
+
awaitSelections?: Await;
|
|
34
|
+
}) => [Await] extends [false] ? Omit<Selection, "orderBy"> & {
|
|
30
35
|
orderBy: { [K in TableConfig['table']['_'] extends {
|
|
31
36
|
columns: infer Columns;
|
|
32
37
|
} ? keyof Columns : never]?: 'asc' | 'desc' | undefined; };
|
|
33
38
|
where: RelationsFilter<TableConfig, Types['DrizzleRelations']>;
|
|
34
|
-
}
|
|
39
|
+
} : MaybePromise<Omit<Selection, "orderBy"> & {
|
|
40
|
+
orderBy: { [K in TableConfig['table']['_'] extends {
|
|
41
|
+
columns: infer Columns;
|
|
42
|
+
} ? keyof Columns : never]?: 'asc' | 'desc' | undefined; };
|
|
43
|
+
where: RelationsFilter<TableConfig, Types['DrizzleRelations']>;
|
|
44
|
+
}>;
|
|
35
45
|
getArgs: () => ExtraArgs;
|
|
36
46
|
};
|
|
37
47
|
//# sourceMappingURL=connection-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-helpers.d.ts","sourceRoot":"","sources":["../src/connection-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"connection-helpers.d.ts","sourceRoot":"","sources":["../src/connection-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EAEzB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,eAAe,EAEf,qBAAqB,EACtB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAY5D,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE7E,wBAAgB,wBAAwB,CACtC,KAAK,SAAS,WAAW,EACzB,IAAI,SAAS,UAAU,CAAC,KAAK,CAAC,GAAG,MAAM,KAAK,CAAC,kBAAkB,CAAC,EAChE,SAAS,SAAS,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,kBAAkB,CAAC,EAAE,WAAW,CAAC,GAAG,IAAI,EACrF,WAAW,SAAS,qBAAqB,GAAG,KAAK,CAAC,kBAAkB,CAAC,CAAC,IAAI,SAAS,UAAU,CAC3F,KAAK,EACL,MAAM,CAAC,CACR,GACG,CAAC,GACD,IAAI,CAAC,EACT,KAAK,GAAG,IAAI,SAAS,UAAU,CA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,IAgC9C,kBAAkB,YACjD;QACR,+CAA+C;QAC/C,eAAe,CAAC,EAAE,KAAK,CAAC;KACzB;iBAhCQ,GACN,CAAC,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,SAAS;YAAE,OAAO,EAAE,MAAM,OAAO,CAAA;SAAE,GAAG,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,EACxF,KAAK,GACL,MAAM,GACN,SAAS,GACd;eACM,eAAe,CAAC,WAAW,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC;;;;;;;mBAgGM,SAAS;EAehF"}
|
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
var _builder_options_drizzle, _builder_options_drizzle1;
|
|
2
|
+
import { completeValue, isThenable } from '@pothos/core';
|
|
3
|
+
import { drizzleAdapter } from './utils/adapter.js';
|
|
4
|
+
import { checkAwaitSelections } from './utils/await-selections.js';
|
|
2
5
|
import { getSchemaConfig } from './utils/config.js';
|
|
3
6
|
import { drizzleCursorConnectionQuery, getCursorFormatter, wrapConnectionResult } from './utils/cursors.js';
|
|
4
7
|
import { queryFromInfo } from './utils/map-query.js';
|
|
5
8
|
import { getRefFromModel } from './utils/refs.js';
|
|
6
|
-
import {
|
|
7
|
-
export function drizzleConnectionHelpers(builder, refOrType, { select, resolveNode, query, args: createArgs, maxSize = (_builder_options_drizzle = builder.options.drizzle) === null || _builder_options_drizzle === void 0 ? void 0 : _builder_options_drizzle.maxConnectionSize, defaultSize = (_builder_options_drizzle1 = builder.options.drizzle) === null || _builder_options_drizzle1 === void 0 ? void 0 : _builder_options_drizzle1.defaultConnectionSize }) {
|
|
9
|
+
import { omitUndefinedKeys } from './utils/selections.js';
|
|
10
|
+
export function drizzleConnectionHelpers(builder, refOrType, { select, resolveNode, query, args: createArgs, maxSize = (_builder_options_drizzle = builder.options.drizzle) === null || _builder_options_drizzle === void 0 ? void 0 : _builder_options_drizzle.maxConnectionSize, defaultSize = (_builder_options_drizzle1 = builder.options.drizzle) === null || _builder_options_drizzle1 === void 0 ? void 0 : _builder_options_drizzle1.defaultConnectionSize } = {}) {
|
|
8
11
|
const config = getSchemaConfig(builder);
|
|
12
|
+
const adapter = drizzleAdapter(config);
|
|
9
13
|
const tableName = typeof refOrType === 'string' ? refOrType : refOrType.tableName;
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
/** The user's `query`, a promise when its callback is async, which the caller awaits. */ const baseQueryFor = (args, ctx)=>completeValue(typeof query === 'function' ? query(args, ctx) : query, orEmpty);
|
|
15
|
+
// Built once per helper, so a synchronous `resolve` allocates nothing beyond the connection.
|
|
16
|
+
const resolveList = (baseQuery, list, args, ctx, parent)=>{
|
|
17
|
+
const { select, cursorFields } = getQueryArgs(args, ctx, baseQuery);
|
|
12
18
|
const formatCursor = getCursorFormatter(cursorFields, config);
|
|
13
19
|
return wrapConnectionResult(list, args, select.limit, formatCursor, resolveNode !== null && resolveNode !== void 0 ? resolveNode : (edge)=>edge, parent);
|
|
20
|
+
};
|
|
21
|
+
function resolve(list, args, ctx, parent) {
|
|
22
|
+
const baseQuery = baseQueryFor(args, ctx);
|
|
23
|
+
return isThenable(baseQuery) ? baseQuery.then((resolved)=>resolveList(resolved, list, args, ctx, parent)) : resolveList(baseQuery, list, args, ctx, parent);
|
|
14
24
|
}
|
|
15
|
-
const getQueryArgs = (args, ctx)=>{
|
|
16
|
-
var _ref
|
|
17
|
-
const { limit, orderBy, where, ...fieldQuery } =
|
|
25
|
+
const getQueryArgs = (args, ctx, baseQuery)=>{
|
|
26
|
+
var _ref;
|
|
27
|
+
const { limit, orderBy, where, ...fieldQuery } = baseQuery;
|
|
18
28
|
const table = config.relations[tableName];
|
|
19
29
|
const { cursorFields, columns, ...connectionQuery } = drizzleCursorConnectionQuery({
|
|
20
30
|
ctx,
|
|
21
31
|
maxSize,
|
|
22
32
|
defaultSize: typeof defaultSize === 'function' ? defaultSize(args, ctx) : defaultSize,
|
|
23
33
|
args,
|
|
24
|
-
orderBy: (
|
|
34
|
+
orderBy: (_ref = typeof orderBy === 'function' ? orderBy(table) : orderBy) !== null && _ref !== void 0 ? _ref : getSchemaConfig(builder).getPrimaryKey(tableName),
|
|
25
35
|
extras: fieldQuery.extras,
|
|
26
36
|
where,
|
|
27
37
|
config,
|
|
@@ -40,16 +50,20 @@ export function drizzleConnectionHelpers(builder, refOrType, { select, resolveNo
|
|
|
40
50
|
cursorFields
|
|
41
51
|
};
|
|
42
52
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
53
|
+
/**
|
|
54
|
+
* The connection's query, built from the helper's own `select` and `query` and the selection
|
|
55
|
+
* beneath the field. Synchronous unless `awaitSelections` says otherwise: an async `select` or
|
|
56
|
+
* `query`, or an async selection beneath the connection, throws rather than returning a promise
|
|
57
|
+
* the declared type denies.
|
|
58
|
+
*/ function getQuery(args, ctx, nestedSelectionOrInfo, options) {
|
|
46
59
|
const nestedSelection = typeof nestedSelectionOrInfo === 'function' ? nestedSelectionOrInfo : (select, path)=>queryFromInfo({
|
|
47
60
|
info: nestedSelectionOrInfo,
|
|
48
61
|
context: ctx,
|
|
49
62
|
config,
|
|
50
|
-
select,
|
|
63
|
+
select: select,
|
|
51
64
|
path
|
|
52
65
|
});
|
|
66
|
+
// Both callbacks start now; the query waits for whichever of them is async.
|
|
53
67
|
const nestedSelect = select ? select((sel)=>nestedSelection(sel, [
|
|
54
68
|
'edges',
|
|
55
69
|
'node'
|
|
@@ -57,20 +71,39 @@ export function drizzleConnectionHelpers(builder, refOrType, { select, resolveNo
|
|
|
57
71
|
'edges',
|
|
58
72
|
'node'
|
|
59
73
|
]);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
74
|
+
let baseQuery;
|
|
75
|
+
try {
|
|
76
|
+
baseQuery = baseQueryFor(args, ctx);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
// The selection has already started. Preserve the query error while handling any
|
|
79
|
+
// later rejection from the selection that this invocation can no longer consume.
|
|
80
|
+
if (isThenable(nestedSelect)) {
|
|
81
|
+
nestedSelect.then(()=>{}, ()=>{});
|
|
82
|
+
}
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
const built = isThenable(nestedSelect) || isThenable(baseQuery) ? Promise.all([
|
|
86
|
+
nestedSelect,
|
|
87
|
+
baseQuery
|
|
88
|
+
]).then(([nested, base])=>buildQuery(nested, base, args, ctx)) : buildQuery(nestedSelect, baseQuery, args, ctx);
|
|
89
|
+
return checkAwaitSelections(built, options === null || options === void 0 ? void 0 : options.awaitSelections, 'getQuery', `the ${String(tableName)} connection`);
|
|
90
|
+
}
|
|
91
|
+
// Built once per helper, so a synchronous `getQuery` allocates nothing beyond the query.
|
|
92
|
+
function buildQuery(nestedSelect, baseQuery, args, ctx) {
|
|
93
|
+
const node = adapter.createNode(config.relations[tableName]);
|
|
94
|
+
adapter.mergeQuery(node, getQueryArgs(args, ctx, baseQuery).select);
|
|
63
95
|
if (typeof nestedSelect === 'object' && nestedSelect) {
|
|
64
|
-
|
|
96
|
+
adapter.mergeQuery(node, nestedSelect);
|
|
65
97
|
}
|
|
66
|
-
const baseQuery = typeof query === 'function' ? query(args, ctx) : query !== null && query !== void 0 ? query : {};
|
|
67
|
-
const queryResult = selectionToQuery(config, selectState);
|
|
68
98
|
return omitUndefinedKeys({
|
|
69
99
|
...baseQuery,
|
|
70
|
-
...
|
|
100
|
+
...adapter.toQuery(node)
|
|
71
101
|
});
|
|
72
102
|
}
|
|
73
103
|
const getArgs = ()=>createArgs ? builder.args(createArgs) : {};
|
|
104
|
+
function orEmpty(baseQuery) {
|
|
105
|
+
return baseQuery !== null && baseQuery !== void 0 ? baseQuery : {};
|
|
106
|
+
}
|
|
74
107
|
return {
|
|
75
108
|
ref: typeof refOrType === 'string' ? getRefFromModel(refOrType, builder) : refOrType,
|
|
76
109
|
resolve,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connection-helpers.ts"],"names":["builder","
|
|
1
|
+
{"version":3,"sources":["../src/connection-helpers.ts"],"names":["builder","completeValue","isThenable","drizzleAdapter","checkAwaitSelections","getSchemaConfig","drizzleCursorConnectionQuery","getCursorFormatter","wrapConnectionResult","queryFromInfo","getRefFromModel","omitUndefinedKeys","drizzleConnectionHelpers","refOrType","select","resolveNode","query","args","createArgs","maxSize","options","drizzle","maxConnectionSize","defaultSize","defaultConnectionSize","config","adapter","tableName","baseQueryFor","ctx","orEmpty","resolveList","baseQuery","list","parent","cursorFields","getQueryArgs","formatCursor","limit","edge","resolve","then","resolved","orderBy","where","fieldQuery","table","relations","columns","connectionQuery","getPrimaryKey","extras","Math","abs","getQuery","nestedSelectionOrInfo","nestedSelection","path","info","context","nestedSelect","sel","error","built","Promise","all","nested","base","buildQuery","awaitSelections","String","node","createNode","mergeQuery","toQuery","getArgs","ref"],"mappings":"IAgEcA,0BACIA;AAjElB,SACEC,aAAa,EAGbC,UAAU,QAIL,eAAe;AAYtB,SAASC,cAAc,QAAQ,qBAAqB;AACpD,SAASC,oBAAoB,QAAQ,8BAA8B;AACnE,SAASC,eAAe,QAAQ,oBAAoB;AACpD,SAEEC,4BAA4B,EAC5BC,kBAAkB,EAClBC,oBAAoB,QACf,qBAAqB;AAC5B,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,eAAe,QAAQ,kBAAkB;AAClD,SAASC,iBAAiB,QAA2B,wBAAwB;AAE7E,OAAO,SAASC,yBAwBdZ,OAA+C,EAC/Ca,SAAe,EACf,EACEC,MAAM,EACNC,WAAW,EACXC,KAAK,EACLC,MAAMC,UAAU,EAChBC,WAAUnB,2BAAAA,QAAQoB,OAAO,CAACC,OAAO,cAAvBrB,+CAAAA,yBAAyBsB,iBAAiB,EACpDC,eAAcvB,4BAAAA,QAAQoB,OAAO,CAACC,OAAO,cAAvBrB,gDAAAA,0BAAyBwB,qBAAqB,EA2B7D,GAAG,CAAC,CAAC;IAEN,MAAMC,SAASpB,gBAAgBL;IAC/B,MAAM0B,UAAUvB,eAAesB;IAC/B,MAAME,YACJ,O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