@pothos/plugin-drizzle 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/drizzle/meta/_journal.json +1 -1
- package/dts/drizzle-field-builder.d.ts +9 -9
- package/dts/drizzle-field-builder.d.ts.map +1 -1
- package/dts/global-types.d.ts +7 -7
- package/dts/global-types.d.ts.map +1 -1
- package/dts/index.d.ts +2 -2
- package/dts/index.d.ts.map +1 -1
- package/dts/interface-ref.d.ts +2 -2
- package/dts/interface-ref.d.ts.map +1 -1
- package/dts/model-loader.d.ts +7 -5
- package/dts/model-loader.d.ts.map +1 -1
- package/dts/node-ref.d.ts +1 -1
- package/dts/node-ref.d.ts.map +1 -1
- package/dts/object-ref.d.ts +1 -1
- package/dts/object-ref.d.ts.map +1 -1
- package/dts/types.d.ts +21 -14
- package/dts/types.d.ts.map +1 -1
- package/dts/utils/config.d.ts +4 -2
- package/dts/utils/config.d.ts.map +1 -1
- package/dts/utils/cursors.d.ts +7 -7
- package/dts/utils/cursors.d.ts.map +1 -1
- package/dts/utils/deep-equal.d.ts.map +1 -1
- package/dts/utils/drizzle-graphql.d.ts +1 -1
- package/dts/utils/drizzle-graphql.d.ts.map +1 -1
- package/dts/utils/loader-map.d.ts +1 -1
- package/dts/utils/loader-map.d.ts.map +1 -1
- package/dts/utils/map-query.d.ts +3 -3
- package/dts/utils/map-query.d.ts.map +1 -1
- package/dts/utils/refs.d.ts +2 -2
- package/dts/utils/refs.d.ts.map +1 -1
- package/dts/utils/selections.d.ts +3 -3
- package/dts/utils/selections.d.ts.map +1 -1
- package/dts/utils/usage.d.ts.map +1 -1
- package/esm/drizzle-field-builder.d.ts +9 -9
- package/esm/drizzle-field-builder.d.ts.map +1 -1
- package/esm/global-types.d.ts +7 -7
- package/esm/global-types.d.ts.map +1 -1
- package/esm/index.d.ts +2 -2
- package/esm/index.d.ts.map +1 -1
- package/esm/interface-ref.d.ts +2 -2
- package/esm/interface-ref.d.ts.map +1 -1
- package/esm/model-loader.d.ts +7 -5
- package/esm/model-loader.d.ts.map +1 -1
- package/esm/node-ref.d.ts +1 -1
- package/esm/node-ref.d.ts.map +1 -1
- package/esm/object-ref.d.ts +1 -1
- package/esm/object-ref.d.ts.map +1 -1
- package/esm/src/drizzle-field-builder.js +10 -9
- package/esm/src/drizzle-field-builder.js.map +1 -1
- package/esm/src/field-builder.js +4 -4
- package/esm/src/field-builder.js.map +1 -1
- package/esm/src/global-types.js +1 -1
- package/esm/src/global-types.js.map +1 -1
- package/esm/src/index.js +4 -4
- package/esm/src/index.js.map +1 -1
- package/esm/src/interface-ref.js.map +1 -1
- package/esm/src/model-loader.js +9 -6
- package/esm/src/model-loader.js.map +1 -1
- package/esm/src/object-ref.js +4 -2
- package/esm/src/object-ref.js.map +1 -1
- package/esm/src/schema-builder.js +19 -18
- package/esm/src/schema-builder.js.map +1 -1
- package/esm/src/types.js.map +1 -1
- package/esm/src/utils/config.js +15 -2
- package/esm/src/utils/config.js.map +1 -1
- package/esm/src/utils/cursors.js +6 -6
- package/esm/src/utils/cursors.js.map +1 -1
- package/esm/src/utils/deep-equal.js +1 -1
- package/esm/src/utils/deep-equal.js.map +1 -1
- package/esm/src/utils/drizzle-graphql.js +44 -21
- package/esm/src/utils/drizzle-graphql.js.map +1 -1
- package/esm/src/utils/loader-map.js +4 -5
- package/esm/src/utils/loader-map.js.map +1 -1
- package/esm/src/utils/map-query.js +1 -3
- package/esm/src/utils/map-query.js.map +1 -1
- package/esm/src/utils/refs.js.map +1 -1
- package/esm/src/utils/selections.js +3 -3
- package/esm/src/utils/selections.js.map +1 -1
- package/esm/src/utils/usage.js +0 -1
- package/esm/src/utils/usage.js.map +1 -1
- package/esm/types.d.ts +21 -14
- package/esm/types.d.ts.map +1 -1
- package/esm/utils/config.d.ts +4 -2
- package/esm/utils/config.d.ts.map +1 -1
- package/esm/utils/cursors.d.ts +7 -7
- package/esm/utils/cursors.d.ts.map +1 -1
- package/esm/utils/deep-equal.d.ts.map +1 -1
- package/esm/utils/drizzle-graphql.d.ts +1 -1
- package/esm/utils/drizzle-graphql.d.ts.map +1 -1
- package/esm/utils/loader-map.d.ts +1 -1
- package/esm/utils/loader-map.d.ts.map +1 -1
- package/esm/utils/map-query.d.ts +3 -3
- package/esm/utils/map-query.d.ts.map +1 -1
- package/esm/utils/refs.d.ts +2 -2
- package/esm/utils/refs.d.ts.map +1 -1
- package/esm/utils/selections.d.ts +3 -3
- package/esm/utils/selections.d.ts.map +1 -1
- package/esm/utils/usage.d.ts.map +1 -1
- package/lib/src/drizzle-field-builder.js +9 -8
- package/lib/src/drizzle-field-builder.js.map +1 -1
- package/lib/src/field-builder.js +4 -4
- package/lib/src/field-builder.js.map +1 -1
- package/lib/src/global-types.js +1 -1
- package/lib/src/global-types.js.map +1 -1
- package/lib/src/index.js +4 -4
- package/lib/src/index.js.map +1 -1
- package/lib/src/interface-ref.js.map +1 -1
- package/lib/src/model-loader.js +10 -6
- package/lib/src/model-loader.js.map +1 -1
- package/lib/src/object-ref.js +3 -1
- package/lib/src/object-ref.js.map +1 -1
- package/lib/src/schema-builder.js +19 -18
- package/lib/src/schema-builder.js.map +1 -1
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/config.js +26 -5
- package/lib/src/utils/config.js.map +1 -1
- package/lib/src/utils/cursors.js +7 -6
- package/lib/src/utils/cursors.js.map +1 -1
- package/lib/src/utils/deep-equal.js +1 -1
- package/lib/src/utils/deep-equal.js.map +1 -1
- package/lib/src/utils/drizzle-graphql.js +53 -21
- package/lib/src/utils/drizzle-graphql.js.map +1 -1
- package/lib/src/utils/loader-map.js +4 -5
- package/lib/src/utils/loader-map.js.map +1 -1
- package/lib/src/utils/map-query.js +2 -4
- package/lib/src/utils/map-query.js.map +1 -1
- package/lib/src/utils/refs.js.map +1 -1
- package/lib/src/utils/selections.js +4 -4
- package/lib/src/utils/selections.js.map +1 -1
- package/lib/src/utils/usage.js +0 -1
- package/lib/src/utils/usage.js.map +1 -1
- package/package.json +11 -11
- package/src/drizzle-field-builder.ts +38 -27
- package/src/field-builder.ts +12 -13
- package/src/global-types.ts +28 -20
- package/src/index.ts +29 -36
- package/src/interface-ref.ts +2 -2
- package/src/model-loader.ts +15 -17
- package/src/node-ref.ts +1 -1
- package/src/object-ref.ts +5 -3
- package/src/schema-builder.ts +26 -25
- package/src/types.ts +54 -48
- package/src/utils/config.ts +35 -5
- package/src/utils/cursors.ts +21 -22
- package/src/utils/deep-equal.ts +0 -1
- package/src/utils/drizzle-graphql.ts +53 -14
- package/src/utils/loader-map.ts +5 -7
- package/src/utils/map-query.ts +20 -23
- package/src/utils/refs.ts +2 -2
- package/src/utils/selections.ts +8 -9
- package/src/utils/usage.ts +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/selections.ts"],"names":["createState","mergeSelection","mergeState","selectionCompatible","selectionToQuery","stateCompatible","state","selectionMap","ignoreQuery","Object","keys","query","length","with","withSelection","extras","columns","entries","some","key","value","has","get","resolvedExtras","table","getOperators","sql","fieldAlias","deepEqual","newState","name","relationState","allColumns","add","set","parent","Set","Map","mappings","depth","config","
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/selections.ts"],"names":["createState","mergeSelection","mergeState","selectionCompatible","selectionToQuery","stateCompatible","state","selectionMap","ignoreQuery","Object","keys","query","length","with","withSelection","extras","columns","entries","some","key","value","has","get","resolvedExtras","table","getOperators","sql","fieldAlias","deepEqual","newState","name","relationState","allColumns","add","set","parent","Set","Map","mappings","depth","config","relation","relations","PothosValidationError","dbName","merge","dbToSchema","referencedTableName","selection","relatedState","primaryKey","forEach","sel"],"mappings":";;;;;;;;;;;IAwGgBA,WAAW;eAAXA;;IAcAC,cAAc;eAAdA;;IApCAC,UAAU;eAAVA;;IAvDAC,mBAAmB;eAAnBA;;IAsJAC,gBAAgB;eAAhBA;;IA7GAC,eAAe;eAAfA;;;sBApEsB;4BAQ/B;2BAEm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AAC;IACX;IAEA,IAAIT,MAAM0B,UAAU,EAAE;QACpB,KAAK,MAAMb,OAAOV,OAAOC,IAAI,CAACJ,MAAMkB,KAAK,CAACR,OAAO,EAAG;YAClDL,MAAMK,OAAO,AAAC,CAACG,IAAI,GAAG;QACxB;IACF,OAAO;QACL,KAAK,MAAMA,OAAOb,MAAMU,OAAO,CAAE;YAC/BL,MAAMK,OAAO,AAAC,CAACG,IAAI,GAAG;QACxB;QACA,KAAK,MAAM,EAAEW,IAAI,EAAE,IAAIxB,MAAMkB,KAAK,CAAC0B,UAAU,CAAE;YAC7CvC,MAAMK,OAAO,AAAC,CAACc,KAAK,GAAG;QACzB;IACF;IAEA,KAAK,MAAM,CAACX,KAAKC,MAAM,IAAId,MAAMS,MAAM,CAAE;QACvCJ,MAAMI,MAAM,AAAC,CAACI,IAAI,GAAGC;IACvB;IAEAd,MAAMO,IAAI,CAACsC,OAAO,CAAC,CAACC,KAAKX;QACvB9B,MAAME,IAAI,AAAC,CAAC4B,SAAS,GAAGrC,iBAAiBgD;IAC3C;IAEA,OAAOzC;AACT"}
|
package/lib/src/utils/usage.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/usage.ts"],"names":["extendWithUsage","isUsed","usageSymbol","wrapWithUsageCheck","Symbol","for","obj","result","used","Object","defineProperty","get","set","value","enumerable","key","keys","configurable","original","extension"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/usage.ts"],"names":["extendWithUsage","isUsed","usageSymbol","wrapWithUsageCheck","Symbol","for","obj","result","used","Object","defineProperty","get","set","value","enumerable","key","keys","configurable","original","extension"],"mappings":";;;;;;;;;;;IAoCgBA,eAAe;eAAfA;;IAJAC,MAAM;eAANA;;IAhCHC,WAAW;eAAXA;;IAEGC,kBAAkB;eAAlBA;;;AAFT,MAAMD,cAAcE,OAAOC,GAAG,CAAC;AAE/B,SAASF,mBAAqCG,GAAM;IACzD,MAAMC,SAAS,CAAC;IAChB,IAAIC,OAAO;IAEXC,OAAOC,cAAc,CAACH,QAAQL,aAAa;QACzCS;YACE,OAAOH;QACT;QACAI,KAAIC,KAAc;YAChBL,OAAOK;QACT;QACAC,YAAY;IACd;IAEA,KAAK,MAAMC,OAAON,OAAOO,IAAI,CAACV,KAAM;QAClC,2CAA2C;QAC3CE,OAAO;QACPC,OAAOC,cAAc,CAACH,QAAQQ,KAAK;YACjCD,YAAY;YACZG,cAAc;YACdN;gBACEH,OAAO;gBACP,OAAOF,GAAG,CAACS,IAAe;YAC5B;QACF;IACF;IAEA,OAAOR;AACT;AAEO,SAASN,OAAOK,GAAW;IAChC,OAAO,CAAEJ,CAAAA,eAAeI,GAAE,KAAM,AAACA,GAAkC,CAACJ,YAAY;AAClF;AAEO,SAASF,gBACdkB,QAAW,EACXC,SAAY;IAEZ,IAAI,CAAEjB,CAAAA,eAAegB,QAAO,GAAI;QAC9B,OAAO;YAAE,GAAGA,QAAQ;YAAE,GAAGC,SAAS;QAAC;IACrC;IAEA,MAAMZ,SAAS;QAAE,GAAGY,SAAS;IAAC;IAE9B,KAAK,MAAMJ,OAAO;QAACb;WAAgBO,OAAOO,IAAI,CAACE;KAAU,CAAE;QACzD,IAAIH,OAAOR,QAAQ;YACjB;QACF;QAEAE,OAAOC,cAAc,CAACH,QAAQQ,KAAK;YACjCD,YAAYC,QAAQb;YACpBe,cAAcF,QAAQb;YACtBS;gBACE,OAAOO,QAAQ,CAACH,IAAe;YACjC;QACF;IACF;IAEA,OAAOR;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pothos/plugin-drizzle",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "A Pothos plugin for drizzle",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./dts/index.d.ts",
|
|
@@ -35,23 +35,23 @@
|
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@pothos/core": "*",
|
|
38
|
-
"graphql": "
|
|
38
|
+
"graphql": ">=16.6.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@libsql/client": "^0.
|
|
41
|
+
"@libsql/client": "^0.8.0",
|
|
42
42
|
"drizzle-graphql": "^0.8.4",
|
|
43
|
-
"drizzle-kit": "^0.23.
|
|
44
|
-
"drizzle-orm": "^0.32.
|
|
43
|
+
"drizzle-kit": "^0.23.1",
|
|
44
|
+
"drizzle-orm": "^0.32.1",
|
|
45
45
|
"graphql": "^16.8.1",
|
|
46
46
|
"graphql-scalars": "^1.23.0",
|
|
47
47
|
"graphql-tag": "^2.12.6",
|
|
48
48
|
"postgres": "^3.4.4",
|
|
49
|
-
"@pothos/core": "4.0
|
|
50
|
-
"@pothos/plugin-add-graphql": "4.0
|
|
51
|
-
"@pothos/plugin-relay": "4.0
|
|
52
|
-
"@pothos/plugin-scope-auth": "4.0
|
|
53
|
-
"@pothos/plugin-with-input": "4.0
|
|
54
|
-
"@pothos/test-utils": "2.0
|
|
49
|
+
"@pothos/core": "4.1.0",
|
|
50
|
+
"@pothos/plugin-add-graphql": "4.1.0",
|
|
51
|
+
"@pothos/plugin-relay": "4.1.0",
|
|
52
|
+
"@pothos/plugin-scope-auth": "4.1.0",
|
|
53
|
+
"@pothos/plugin-with-input": "4.1.0",
|
|
54
|
+
"@pothos/test-utils": "2.1.0"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"type": "tsc --project tsconfig.type.json",
|
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
import { getOperators, InferModelFromColumns, Many, TableRelationalConfig } from 'drizzle-orm';
|
|
2
1
|
import {
|
|
3
|
-
CompatibleTypes,
|
|
4
|
-
ExposeNullability,
|
|
5
|
-
FieldKind,
|
|
6
|
-
FieldRef,
|
|
7
|
-
InputFieldMap,
|
|
8
|
-
InterfaceParam,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
NormalizeArgs,
|
|
2
|
+
type CompatibleTypes,
|
|
3
|
+
type ExposeNullability,
|
|
4
|
+
type FieldKind,
|
|
5
|
+
type FieldRef,
|
|
6
|
+
type InputFieldMap,
|
|
7
|
+
type InterfaceParam,
|
|
8
|
+
type MaybePromise,
|
|
9
|
+
type NormalizeArgs,
|
|
12
10
|
ObjectRef,
|
|
13
|
-
PluginName,
|
|
11
|
+
type PluginName,
|
|
14
12
|
PothosSchemaError,
|
|
15
13
|
RootFieldBuilder,
|
|
16
|
-
SchemaTypes,
|
|
17
|
-
ShapeFromTypeParam,
|
|
18
|
-
TypeParam,
|
|
14
|
+
type SchemaTypes,
|
|
15
|
+
type ShapeFromTypeParam,
|
|
16
|
+
type TypeParam,
|
|
17
|
+
isThenable,
|
|
19
18
|
} from '@pothos/core';
|
|
20
19
|
import {
|
|
20
|
+
type InferModelFromColumns,
|
|
21
|
+
Many,
|
|
22
|
+
type TableRelationalConfig,
|
|
23
|
+
getOperators,
|
|
24
|
+
} from 'drizzle-orm';
|
|
25
|
+
import type { DrizzleRef } from './interface-ref';
|
|
26
|
+
import type {
|
|
21
27
|
DrizzleConnectionShape,
|
|
22
28
|
ListRelation,
|
|
23
29
|
RelatedConnectionOptions,
|
|
@@ -26,18 +32,17 @@ import {
|
|
|
26
32
|
TypesForRelation,
|
|
27
33
|
VariantFieldOptions,
|
|
28
34
|
} from './types';
|
|
29
|
-
import {
|
|
35
|
+
import { getSchemaConfig } from './utils/config';
|
|
30
36
|
import {
|
|
31
37
|
drizzleCursorConnectionQuery,
|
|
32
38
|
getCursorFormatter,
|
|
33
39
|
wrapConnectionResult,
|
|
34
40
|
} from './utils/cursors';
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
41
|
+
import { getRefFromModel } from './utils/refs';
|
|
42
|
+
import type { SelectionMap } from './utils/selections';
|
|
37
43
|
|
|
38
44
|
// Workaround for FieldKind not being extended on Builder classes
|
|
39
45
|
const RootBuilder: {
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/prefer-function-type
|
|
41
46
|
new <Types extends SchemaTypes, Shape, Kind extends FieldKind>(
|
|
42
47
|
builder: PothosSchemaTypes.SchemaBuilder<Types>,
|
|
43
48
|
kind: FieldKind,
|
|
@@ -191,10 +196,12 @@ export class DrizzleObjectFieldBuilder<
|
|
|
191
196
|
connectionOptions = {},
|
|
192
197
|
edgeOptions = {},
|
|
193
198
|
) {
|
|
194
|
-
const relationField =
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
199
|
+
const relationField = getSchemaConfig(this.builder).schema?.[this.table].relations[
|
|
200
|
+
name as string
|
|
201
|
+
];
|
|
202
|
+
const relatedModel = getSchemaConfig(this.builder).schema?.[
|
|
203
|
+
relationField?.referencedTableName!
|
|
204
|
+
]!;
|
|
198
205
|
|
|
199
206
|
if (!relationField) {
|
|
200
207
|
throw new PothosSchemaError(
|
|
@@ -236,7 +243,7 @@ export class DrizzleObjectFieldBuilder<
|
|
|
236
243
|
const relationSelect = (
|
|
237
244
|
args: object,
|
|
238
245
|
context: object,
|
|
239
|
-
nestedQuery: (query: unknown, path?: unknown) => { select?:
|
|
246
|
+
nestedQuery: (query: unknown, path?: unknown) => { select?: object },
|
|
240
247
|
) => {
|
|
241
248
|
typeName ??= this.builder.configStore.getTypeConfig(ref).name;
|
|
242
249
|
const nested = nestedQuery(getQuery(args, context).select, {
|
|
@@ -326,8 +333,11 @@ export class DrizzleObjectFieldBuilder<
|
|
|
326
333
|
const ref: DrizzleRef<Types> =
|
|
327
334
|
typeof variant === 'string' ? getRefFromModel(variant, this.builder) : variant;
|
|
328
335
|
|
|
329
|
-
const selfSelect = (
|
|
330
|
-
|
|
336
|
+
const selfSelect = (
|
|
337
|
+
_args: object,
|
|
338
|
+
_context: object,
|
|
339
|
+
nestedQuery: (query: unknown) => unknown,
|
|
340
|
+
) => nestedQuery({});
|
|
331
341
|
|
|
332
342
|
return this.field({
|
|
333
343
|
...(options as {}),
|
|
@@ -374,8 +384,9 @@ export class DrizzleObjectFieldBuilder<
|
|
|
374
384
|
>
|
|
375
385
|
): FieldRef<Types, TypesForRelation<Types, TableConfig['relations'][Field]>, 'Object'> {
|
|
376
386
|
const [options = {} as never] = allArgs;
|
|
377
|
-
const relationField =
|
|
378
|
-
|
|
387
|
+
const relationField = getSchemaConfig(this.builder).schema?.[this.table].relations[
|
|
388
|
+
name as string
|
|
389
|
+
];
|
|
379
390
|
|
|
380
391
|
if (!relationField) {
|
|
381
392
|
throw new PothosSchemaError(
|
package/src/field-builder.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { type FieldKind, ObjectRef, RootFieldBuilder, type SchemaTypes } from '@pothos/core';
|
|
2
|
+
import type { FieldRef } from '@pothos/core';
|
|
3
|
+
import type { TableRelationalConfig } from 'drizzle-orm';
|
|
4
|
+
import type { GraphQLResolveInfo } from 'graphql';
|
|
5
|
+
import type { DrizzleRef } from './interface-ref';
|
|
6
|
+
import type { DrizzleConnectionFieldOptions } from './types';
|
|
7
|
+
import { getSchemaConfig } from './utils/config';
|
|
8
|
+
import { resolveDrizzleCursorConnection } from './utils/cursors';
|
|
3
9
|
import { queryFromInfo } from './utils/map-query';
|
|
4
10
|
import { getRefFromModel } from './utils/refs';
|
|
5
|
-
import { FieldRef } from '@pothos/core';
|
|
6
|
-
import { DrizzleRef } from './interface-ref';
|
|
7
|
-
import { DrizzleConnectionFieldOptions } from './types';
|
|
8
|
-
import { TableRelationalConfig } from 'drizzle-orm';
|
|
9
|
-
import { resolveDrizzleCursorConnection } from './utils/cursors';
|
|
10
|
-
import { getSchemaConfig } from './utils/config';
|
|
11
11
|
|
|
12
12
|
const fieldBuilderProto = RootFieldBuilder.prototype as PothosSchemaTypes.RootFieldBuilder<
|
|
13
13
|
SchemaTypes,
|
|
@@ -125,10 +125,9 @@ fieldBuilderProto.drizzleConnection = function drizzleConnection<
|
|
|
125
125
|
context: {},
|
|
126
126
|
info: GraphQLResolveInfo,
|
|
127
127
|
) => {
|
|
128
|
-
const drizzleModel =
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
]!;
|
|
128
|
+
const drizzleModel = getSchemaConfig(this.builder).schema?.[
|
|
129
|
+
typeof type === 'string' ? type : (ref as DrizzleRef<SchemaTypes>).tableName
|
|
130
|
+
]!;
|
|
132
131
|
|
|
133
132
|
return resolveDrizzleCursorConnection(
|
|
134
133
|
drizzleModel,
|
|
@@ -158,7 +157,7 @@ fieldBuilderProto.drizzleConnection = function drizzleConnection<
|
|
|
158
157
|
: {
|
|
159
158
|
...connectionOptions,
|
|
160
159
|
extensions: {
|
|
161
|
-
...(connectionOptions as Record<string,
|
|
160
|
+
...(connectionOptions as Record<string, object> | undefined)?.extensions,
|
|
162
161
|
},
|
|
163
162
|
},
|
|
164
163
|
edgeOptions,
|
package/src/global-types.ts
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-empty-interface */
|
|
3
1
|
import type {
|
|
4
|
-
BuildQueryResult,
|
|
5
|
-
DBQueryConfig,
|
|
6
|
-
ExtractTablesWithRelations,
|
|
7
|
-
SQL,
|
|
8
|
-
TableRelationalConfig,
|
|
9
|
-
} from 'drizzle-orm';
|
|
10
|
-
import {
|
|
11
2
|
FieldKind,
|
|
12
3
|
FieldMap,
|
|
13
4
|
FieldNullability,
|
|
@@ -21,9 +12,16 @@ import {
|
|
|
21
12
|
ShapeFromTypeParam,
|
|
22
13
|
TypeParam,
|
|
23
14
|
} from '@pothos/core';
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
import type {
|
|
16
|
+
BuildQueryResult,
|
|
17
|
+
DBQueryConfig,
|
|
18
|
+
ExtractTablesWithRelations,
|
|
19
|
+
SQL,
|
|
20
|
+
TableRelationalConfig,
|
|
21
|
+
} from 'drizzle-orm';
|
|
22
|
+
import type { DrizzleObjectFieldBuilder } from './drizzle-field-builder';
|
|
23
|
+
import type { DrizzleInterfaceRef, DrizzleRef } from './interface-ref';
|
|
24
|
+
import type { DrizzleObjectRef, drizzleTableKey } from './object-ref';
|
|
27
25
|
import type {
|
|
28
26
|
AddGraphQLInputTypeOptions,
|
|
29
27
|
DrizzleConnectionFieldOptions,
|
|
@@ -35,13 +33,13 @@ import type {
|
|
|
35
33
|
DrizzleObjectFieldOptions,
|
|
36
34
|
DrizzleObjectOptions,
|
|
37
35
|
DrizzlePluginOptions,
|
|
38
|
-
drizzleTableName,
|
|
39
36
|
ShapeFromConnection,
|
|
37
|
+
drizzleTableName,
|
|
40
38
|
} from './types';
|
|
41
39
|
|
|
40
|
+
import type { GraphQLInputObjectType } from 'graphql';
|
|
42
41
|
import type { PothosDrizzlePlugin } from '.';
|
|
43
|
-
import { DrizzleNodeRef } from './node-ref';
|
|
44
|
-
import { GraphQLInputObjectType } from 'graphql';
|
|
42
|
+
import type { DrizzleNodeRef } from './node-ref';
|
|
45
43
|
|
|
46
44
|
declare global {
|
|
47
45
|
export namespace PothosSchemaTypes {
|
|
@@ -274,7 +272,9 @@ declare global {
|
|
|
274
272
|
Param extends
|
|
275
273
|
| keyof Types['DrizzleRelationSchema']
|
|
276
274
|
| [keyof Types['DrizzleRelationSchema']]
|
|
275
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
277
276
|
| DrizzleRef<any>
|
|
277
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
278
278
|
| [DrizzleRef<any>],
|
|
279
279
|
Nullable extends FieldNullability<Type>,
|
|
280
280
|
ResolveShape,
|
|
@@ -284,9 +284,11 @@ declare global {
|
|
|
284
284
|
? Param
|
|
285
285
|
: Param extends [keyof Types['DrizzleRelationSchema']]
|
|
286
286
|
? Param[0]
|
|
287
|
-
:
|
|
287
|
+
: // biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
288
|
+
Param extends DrizzleRef<any, infer T>
|
|
288
289
|
? T & keyof Types['DrizzleRelationSchema']
|
|
289
|
-
:
|
|
290
|
+
: // biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
291
|
+
Param extends [DrizzleRef<any, infer T>]
|
|
290
292
|
? T & keyof Types['DrizzleRelationSchema']
|
|
291
293
|
: never,
|
|
292
294
|
Type extends TypeParam<Types> = ObjectRef<
|
|
@@ -314,12 +316,13 @@ declare global {
|
|
|
314
316
|
|
|
315
317
|
drizzleConnection: 'relay' extends PluginName
|
|
316
318
|
? <
|
|
317
|
-
Type extends
|
|
319
|
+
Type extends // biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
318
320
|
| DrizzleRef<any, keyof Types['DrizzleRelationSchema']>
|
|
319
321
|
| keyof Types['DrizzleRelationSchema'],
|
|
320
322
|
Nullable extends boolean,
|
|
321
323
|
ResolveReturnShape,
|
|
322
324
|
Args extends InputFieldMap = {},
|
|
325
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
323
326
|
Shape = Type extends DrizzleRef<any, keyof Types['DrizzleRelationSchema'], infer S>
|
|
324
327
|
? S
|
|
325
328
|
: BuildQueryResult<
|
|
@@ -334,6 +337,7 @@ declare global {
|
|
|
334
337
|
Types,
|
|
335
338
|
ParentShape,
|
|
336
339
|
Type,
|
|
340
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
337
341
|
Types['DrizzleRelationSchema'][Type extends DrizzleRef<any, infer K>
|
|
338
342
|
? K
|
|
339
343
|
: Type & keyof Types['DrizzleRelationSchema']],
|
|
@@ -386,7 +390,9 @@ declare global {
|
|
|
386
390
|
Param extends
|
|
387
391
|
| keyof Types['DrizzleRelationSchema']
|
|
388
392
|
| [keyof Types['DrizzleRelationSchema']]
|
|
393
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
389
394
|
| DrizzleRef<any>
|
|
395
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
390
396
|
| [DrizzleRef<any>],
|
|
391
397
|
Nullable extends FieldNullability<Type>,
|
|
392
398
|
ResolveShape,
|
|
@@ -398,9 +404,11 @@ declare global {
|
|
|
398
404
|
? Param
|
|
399
405
|
: Param extends [keyof Types['DrizzleRelationSchema']]
|
|
400
406
|
? Param[0]
|
|
401
|
-
:
|
|
407
|
+
: // biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
408
|
+
Param extends DrizzleRef<any, infer T>
|
|
402
409
|
? T & keyof Types['DrizzleRelationSchema']
|
|
403
|
-
:
|
|
410
|
+
: // biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
411
|
+
Param extends [DrizzleRef<any, infer T>]
|
|
404
412
|
? T & keyof Types['DrizzleRelationSchema']
|
|
405
413
|
: never,
|
|
406
414
|
Type extends TypeParam<Types> = ObjectRef<
|
package/src/index.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import './global-types';
|
|
2
2
|
import './field-builder';
|
|
3
3
|
import './schema-builder';
|
|
4
|
-
import { GraphQLFieldResolver } from 'graphql';
|
|
5
4
|
import SchemaBuilder, {
|
|
6
5
|
BasePlugin,
|
|
7
6
|
createInputValueMapper,
|
|
8
7
|
mapInputFields,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
SchemaTypes,
|
|
8
|
+
type PothosOutputFieldConfig,
|
|
9
|
+
type SchemaTypes,
|
|
12
10
|
} from '@pothos/core';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
11
|
+
import type { GraphQLFieldResolver } from 'graphql';
|
|
12
|
+
import type { ModelLoader } from './model-loader';
|
|
13
|
+
import type { DrizzleGraphQLInputExtensions } from './types';
|
|
15
14
|
import {
|
|
16
15
|
extractFilters,
|
|
17
16
|
extractOrderBy,
|
|
@@ -44,37 +43,31 @@ export class PothosDrizzlePlugin<Types extends SchemaTypes> extends BasePlugin<T
|
|
|
44
43
|
);
|
|
45
44
|
|
|
46
45
|
const argMapper = argMappings
|
|
47
|
-
? createInputValueMapper(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
)
|
|
46
|
+
? createInputValueMapper(argMappings, (input, mappings) => {
|
|
47
|
+
if (!mappings.value) {
|
|
48
|
+
return input;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const { table, tableConfig, inputType } = mappings.value;
|
|
52
|
+
|
|
53
|
+
switch (inputType) {
|
|
54
|
+
case 'orderBy':
|
|
55
|
+
return extractOrderBy(tableConfig, input as never);
|
|
56
|
+
case 'filters':
|
|
57
|
+
return extractFilters(tableConfig, table, input as never);
|
|
58
|
+
case 'insert':
|
|
59
|
+
return remapFromGraphQLSingleInput(input as never, tableConfig);
|
|
60
|
+
case 'update':
|
|
61
|
+
return remapFromGraphQLSingleInput(input as never, tableConfig);
|
|
62
|
+
|
|
63
|
+
default:
|
|
64
|
+
throw new Error(`Unknown drizzle input type: ${inputType}`);
|
|
65
|
+
}
|
|
66
|
+
})
|
|
71
67
|
: null;
|
|
72
68
|
|
|
73
69
|
const argMappers: typeof fieldConfig.argMappers = argMapper
|
|
74
|
-
? [
|
|
75
|
-
...(fieldConfig.argMappers ?? []),
|
|
76
|
-
(args, context, info) => argMapper(args, undefined, context, info),
|
|
77
|
-
]
|
|
70
|
+
? [...(fieldConfig.argMappers ?? []), (args) => argMapper(args, undefined)]
|
|
78
71
|
: fieldConfig.argMappers;
|
|
79
72
|
|
|
80
73
|
if (fieldConfig.kind === 'DrizzleObject' && fieldConfig.pothosOptions.select) {
|
|
@@ -121,12 +114,12 @@ export class PothosDrizzlePlugin<Types extends SchemaTypes> extends BasePlugin<T
|
|
|
121
114
|
const parentTypes = new Set([fieldConfig.parentType]);
|
|
122
115
|
|
|
123
116
|
if (parentConfig.kind === 'Interface' || parentConfig.kind === 'Object') {
|
|
124
|
-
parentConfig.interfaces
|
|
117
|
+
for (const iface of parentConfig.interfaces) {
|
|
125
118
|
const interfaceConfig = this.buildCache.getTypeConfig(iface, 'Interface');
|
|
126
119
|
if (interfaceConfig.extensions?.pothosDrizzleModel) {
|
|
127
120
|
parentTypes.add(interfaceConfig.name);
|
|
128
121
|
}
|
|
129
|
-
}
|
|
122
|
+
}
|
|
130
123
|
}
|
|
131
124
|
|
|
132
125
|
const modelLoader = parentConfig.extensions?.pothosDrizzleLoader as ReturnType<
|
package/src/interface-ref.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InterfaceRef, SchemaTypes } from '@pothos/core';
|
|
2
|
-
import { DrizzleObjectRef, drizzleTableKey } from './object-ref';
|
|
1
|
+
import { InterfaceRef, type SchemaTypes } from '@pothos/core';
|
|
2
|
+
import { type DrizzleObjectRef, drizzleTableKey } from './object-ref';
|
|
3
3
|
|
|
4
4
|
export type DrizzleRef<
|
|
5
5
|
Types extends SchemaTypes,
|
package/src/model-loader.ts
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
sql,
|
|
7
|
-
TableRelationalConfig,
|
|
8
|
-
TablesRelationalConfig,
|
|
9
|
-
} from 'drizzle-orm';
|
|
10
|
-
import { createContextCache, SchemaTypes } from '@pothos/core';
|
|
1
|
+
import { type SchemaTypes, createContextCache } from '@pothos/core';
|
|
2
|
+
import { type Column, type TableRelationalConfig, inArray, sql } from 'drizzle-orm';
|
|
3
|
+
import type { GraphQLResolveInfo } from 'graphql';
|
|
4
|
+
import type { DrizzleClient } from './types';
|
|
5
|
+
import { type PothosDrizzleSchemaConfig, getClient, getSchemaConfig } from './utils/config';
|
|
11
6
|
import { cacheKey, setLoaderMappings } from './utils/loader-map';
|
|
12
7
|
import { selectionStateFromInfo, stateFromInfo } from './utils/map-query';
|
|
13
8
|
import {
|
|
9
|
+
type SelectionMap,
|
|
10
|
+
type SelectionState,
|
|
14
11
|
mergeSelection,
|
|
15
12
|
selectionCompatible,
|
|
16
|
-
SelectionMap,
|
|
17
|
-
SelectionState,
|
|
18
13
|
selectionToQuery,
|
|
19
14
|
} from './utils/selections';
|
|
20
|
-
import { getSchemaConfig, PothosDrizzleSchemaConfig } from './utils/config';
|
|
21
15
|
|
|
22
16
|
interface ResolvablePromise<T> {
|
|
23
17
|
promise: Promise<T>;
|
|
@@ -42,6 +36,7 @@ export class ModelLoader {
|
|
|
42
36
|
table: TableRelationalConfig;
|
|
43
37
|
columns: Column[];
|
|
44
38
|
selectSQL;
|
|
39
|
+
client: DrizzleClient;
|
|
45
40
|
|
|
46
41
|
constructor(
|
|
47
42
|
context: object,
|
|
@@ -59,6 +54,8 @@ export class ModelLoader {
|
|
|
59
54
|
this.columns.length > 1
|
|
60
55
|
? sql`(${sql.join(this.columns, sql`, `)})`
|
|
61
56
|
: this.columns[0].getSQL();
|
|
57
|
+
|
|
58
|
+
this.client = getClient(builder, context);
|
|
62
59
|
}
|
|
63
60
|
|
|
64
61
|
static forModel<Types extends SchemaTypes>(
|
|
@@ -144,7 +141,7 @@ export class ModelLoader {
|
|
|
144
141
|
return result;
|
|
145
142
|
}
|
|
146
143
|
|
|
147
|
-
|
|
144
|
+
stageQuery(selection: SelectionState, query: SelectionMap, model: object) {
|
|
148
145
|
for (const entry of this.staged) {
|
|
149
146
|
if (selectionCompatible(entry.state, query)) {
|
|
150
147
|
mergeSelection(this.config, entry.state, query);
|
|
@@ -173,7 +170,7 @@ export class ModelLoader {
|
|
|
173
170
|
nextTick.promise
|
|
174
171
|
.then(() => {
|
|
175
172
|
const api = (
|
|
176
|
-
this.
|
|
173
|
+
this.client.query as Record<
|
|
177
174
|
string,
|
|
178
175
|
{ findMany: (...args: unknown[]) => Promise<Record<string, unknown>[]> }
|
|
179
176
|
>
|
|
@@ -198,10 +195,11 @@ export class ModelLoader {
|
|
|
198
195
|
|
|
199
196
|
if (result) {
|
|
200
197
|
promise.resolve(result ?? null);
|
|
201
|
-
} else
|
|
198
|
+
} else {
|
|
202
199
|
promise.reject(
|
|
203
200
|
new Error(`Model ${this.modelName}(${this.sqlForModel(model)}) not found`),
|
|
204
201
|
);
|
|
202
|
+
}
|
|
205
203
|
}
|
|
206
204
|
},
|
|
207
205
|
(err) => {
|
|
@@ -217,7 +215,7 @@ export class ModelLoader {
|
|
|
217
215
|
}
|
|
218
216
|
});
|
|
219
217
|
|
|
220
|
-
setTimeout(() =>
|
|
218
|
+
setTimeout(() => nextTick.resolve(), 0);
|
|
221
219
|
|
|
222
220
|
return promise.promise;
|
|
223
221
|
}
|
package/src/node-ref.ts
CHANGED
package/src/object-ref.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ObjectRef,
|
|
3
|
+
type SchemaTypes,
|
|
2
4
|
abstractReturnShapeKey,
|
|
3
5
|
brandWithType,
|
|
4
|
-
ObjectRef,
|
|
5
|
-
SchemaTypes,
|
|
6
6
|
typeBrandKey,
|
|
7
7
|
} from '@pothos/core';
|
|
8
8
|
import type { WithBrand } from './types';
|
|
@@ -30,7 +30,9 @@ export class DrizzleObjectRef<
|
|
|
30
30
|
value: V,
|
|
31
31
|
): V extends T[] ? { [K in keyof V]: WithBrand<V[K]> } : WithBrand<V> {
|
|
32
32
|
if (Array.isArray(value)) {
|
|
33
|
-
|
|
33
|
+
for (const val of value) {
|
|
34
|
+
brandWithType(val, this.name as never);
|
|
35
|
+
}
|
|
34
36
|
|
|
35
37
|
return value as never;
|
|
36
38
|
}
|