@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
package/esm/model-loader.js
CHANGED
|
@@ -11,12 +11,12 @@ function _define_property(obj, key, value) {
|
|
|
11
11
|
}
|
|
12
12
|
return obj;
|
|
13
13
|
}
|
|
14
|
-
import { createContextCache } from '@pothos/core';
|
|
14
|
+
import { createContextCache, isThenable } from '@pothos/core';
|
|
15
|
+
import { cacheKey, Plan, setLoaderMappings, setRowFieldMapping } from '@pothos/selection-mapper';
|
|
15
16
|
import { getColumns, inArray, sql } from 'drizzle-orm';
|
|
17
|
+
import { drizzleAdapter } from './utils/adapter.js';
|
|
16
18
|
import { getClient, getSchemaConfig } from './utils/config.js';
|
|
17
|
-
import {
|
|
18
|
-
import { selectionStateFromInfo, stateFromInfo } from './utils/map-query.js';
|
|
19
|
-
import { mergeSelection, selectionCompatible, selectionToQuery } from './utils/selections.js';
|
|
19
|
+
import { planFromInfo } from './utils/map-query.js';
|
|
20
20
|
export class ModelLoader {
|
|
21
21
|
static forModel(modelName, builder, columns) {
|
|
22
22
|
return createContextCache((model)=>new ModelLoader(model, builder, modelName, columns));
|
|
@@ -33,66 +33,81 @@ export class ModelLoader {
|
|
|
33
33
|
}
|
|
34
34
|
getSelection(info) {
|
|
35
35
|
const key = cacheKey(info.parentType.name, info.path);
|
|
36
|
-
if (!this.
|
|
37
|
-
|
|
38
|
-
this.queryCache.set(key, {
|
|
39
|
-
selection,
|
|
40
|
-
query: selectionToQuery(this.config, selection)
|
|
41
|
-
});
|
|
36
|
+
if (!this.rowCache.has(key)) {
|
|
37
|
+
this.rowCache.set(key, Plan.forParentRow(drizzleAdapter(this.config), this.context, info));
|
|
42
38
|
}
|
|
43
|
-
return this.
|
|
39
|
+
return this.rowCache.get(key);
|
|
44
40
|
}
|
|
45
41
|
getSelectionForField(info, typeName) {
|
|
46
42
|
const key = cacheKey(typeName, info.path);
|
|
47
|
-
if (!this.
|
|
48
|
-
|
|
43
|
+
if (!this.planCache.has(key)) {
|
|
44
|
+
this.planCache.set(key, // Walked without paths, so there is always a plan.
|
|
45
|
+
planFromInfo({
|
|
49
46
|
config: this.config,
|
|
50
47
|
context: this.context,
|
|
51
48
|
info,
|
|
52
49
|
typeName
|
|
53
|
-
});
|
|
54
|
-
this.queryCache.set(key, {
|
|
55
|
-
selection,
|
|
56
|
-
query: selectionToQuery(this.config, selection)
|
|
57
|
-
});
|
|
50
|
+
}));
|
|
58
51
|
}
|
|
59
|
-
return this.
|
|
52
|
+
return this.planCache.get(key);
|
|
60
53
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
/**
|
|
55
|
+
* `model` reloaded with the selection of the field `info` resolves. A synchronous selection
|
|
56
|
+
* stages synchronously, so every row resolved in a tick joins the same batch; only a selection
|
|
57
|
+
* with an async select beneath the field waits for it.
|
|
58
|
+
*/ loadSelection(info, model) {
|
|
59
|
+
const selection = this.getSelection(info);
|
|
60
|
+
return isThenable(selection) ? selection.then((settled)=>this.loadWith(settled, info, model)) : this.loadWith(selection, info, model);
|
|
61
|
+
}
|
|
62
|
+
loadWith(played, info, model) {
|
|
63
|
+
return this.stageQuery(played, model).then((result)=>{
|
|
64
|
+
if (result) {
|
|
65
|
+
const mapping = played.mappings[`${info.parentType.name}@${info.path.key}`];
|
|
66
|
+
if (mapping) {
|
|
67
|
+
// Recorded for the field itself too, so its resolver finds the pathInfo it was planned
|
|
68
|
+
// with, along with the mappings of the fields beneath it. Against `result` alone: this
|
|
69
|
+
// load fetched one row, so the field's own mapping is not the whole field's to claim.
|
|
70
|
+
// A sibling row that falls back on a later tick would otherwise read it as proof of
|
|
71
|
+
// having been loaded and resolve against a row that never carried the data.
|
|
72
|
+
setRowFieldMapping(this.context, info, mapping, result);
|
|
73
|
+
}
|
|
68
74
|
}
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
return result;
|
|
76
|
+
});
|
|
71
77
|
}
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
/** A node loaded by id with the selection beneath the field `info` resolves, as `returnType`. */ loadSelectionForField(info, model, returnType) {
|
|
79
|
+
const selection = this.getSelectionForField(info, returnType);
|
|
80
|
+
return isThenable(selection) ? selection.then((settled)=>this.loadFieldWith(settled.play(), info, model)) : this.loadFieldWith(selection.play(), info, model);
|
|
81
|
+
}
|
|
82
|
+
loadFieldWith(played, info, model) {
|
|
83
|
+
return this.stageQuery(played, model).then((result)=>{
|
|
84
|
+
if (result) {
|
|
85
|
+
// Relay nodes of different types share this field path. Each node plan contributes
|
|
86
|
+
// its type-qualified mappings, as a queryFromInfo plan would.
|
|
87
|
+
setLoaderMappings(this.context, info, played.mappings);
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
});
|
|
79
91
|
}
|
|
80
|
-
stageQuery(
|
|
92
|
+
stageQuery(played, model) {
|
|
81
93
|
for (const entry of this.staged){
|
|
82
|
-
|
|
83
|
-
|
|
94
|
+
// Node to node: the batch takes the field's play whole, never through a query.
|
|
95
|
+
if (this.adapter.canMergeNode(entry.root, played.root)) {
|
|
96
|
+
this.adapter.mergeNode(entry.root, played.root);
|
|
84
97
|
if (!entry.models.has(model)) {
|
|
85
98
|
entry.models.set(model, createResolvablePromise());
|
|
86
99
|
}
|
|
87
100
|
return entry.models.get(model).promise;
|
|
88
101
|
}
|
|
89
102
|
}
|
|
90
|
-
return this.initLoad(
|
|
103
|
+
return this.initLoad(played, model);
|
|
91
104
|
}
|
|
92
|
-
initLoad(
|
|
105
|
+
initLoad(played, model) {
|
|
93
106
|
const promise = createResolvablePromise();
|
|
107
|
+
const root = this.adapter.createNode(played.root.model);
|
|
108
|
+
this.adapter.mergeNode(root, played.root);
|
|
94
109
|
const entry = {
|
|
95
|
-
|
|
110
|
+
root,
|
|
96
111
|
models: new Map([
|
|
97
112
|
[
|
|
98
113
|
model,
|
|
@@ -107,7 +122,7 @@ export class ModelLoader {
|
|
|
107
122
|
this.staged.delete(entry);
|
|
108
123
|
const api = client.query[this.modelName];
|
|
109
124
|
const query = api.findMany({
|
|
110
|
-
...
|
|
125
|
+
...this.adapter.toQuery(entry.root),
|
|
111
126
|
where: {
|
|
112
127
|
RAW: (table)=>inArray(this.selectSQL(table), [
|
|
113
128
|
...entry.models.keys()
|
|
@@ -116,9 +131,17 @@ export class ModelLoader {
|
|
|
116
131
|
});
|
|
117
132
|
query.then((results)=>{
|
|
118
133
|
for (const [model, promise] of entry.models.entries()){
|
|
119
|
-
|
|
134
|
+
// Matched on the columns the batch was keyed by, which are the columns a row of
|
|
135
|
+
// `entry.models` carries: a node loaded by a column other than the primary key
|
|
136
|
+
// has only that one.
|
|
137
|
+
const result = results.find((row)=>this.columns.every((key)=>{
|
|
138
|
+
const name = this.config.columnToTsName(key);
|
|
139
|
+
const actual = row[name];
|
|
140
|
+
const expected = model[name];
|
|
141
|
+
return actual === expected || actual instanceof Date && expected instanceof Date && actual.getTime() === expected.getTime();
|
|
142
|
+
}));
|
|
120
143
|
if (result) {
|
|
121
|
-
promise.resolve(result
|
|
144
|
+
promise.resolve(result);
|
|
122
145
|
} else {
|
|
123
146
|
promise.reject(new Error(`Model ${this.modelName}(${this.sqlForModel(model)}) not found`));
|
|
124
147
|
}
|
|
@@ -140,9 +163,16 @@ export class ModelLoader {
|
|
|
140
163
|
_define_property(this, "context", void 0);
|
|
141
164
|
_define_property(this, "builder", void 0);
|
|
142
165
|
_define_property(this, "modelName", void 0);
|
|
143
|
-
|
|
166
|
+
// One plan per `Type@path`, a promise while a select beneath the field is async. A parent-row
|
|
167
|
+
// plan is played where it is made, since it is never played behind another selection; a field's
|
|
168
|
+
// plan is played per load, so no two loads share a node.
|
|
169
|
+
_define_property(this, "rowCache", new Map());
|
|
170
|
+
_define_property(this, "planCache", new Map());
|
|
171
|
+
// Each batch owns the node it accumulates into, so nothing a cached plan or play holds is
|
|
172
|
+
// changed by a row joining the batch.
|
|
144
173
|
_define_property(this, "staged", new Set());
|
|
145
174
|
_define_property(this, "config", void 0);
|
|
175
|
+
_define_property(this, "adapter", void 0);
|
|
146
176
|
_define_property(this, "table", void 0);
|
|
147
177
|
_define_property(this, "columns", void 0);
|
|
148
178
|
_define_property(this, "primaryKey", void 0);
|
|
@@ -151,6 +181,7 @@ export class ModelLoader {
|
|
|
151
181
|
this.builder = builder;
|
|
152
182
|
this.modelName = modelName;
|
|
153
183
|
this.config = getSchemaConfig(builder);
|
|
184
|
+
this.adapter = drizzleAdapter(this.config);
|
|
154
185
|
this.table = this.config.relations[modelName];
|
|
155
186
|
this.primaryKey = this.config.getPrimaryKey(modelName);
|
|
156
187
|
this.columns = columns !== null && columns !== void 0 ? columns : this.primaryKey;
|
package/esm/model-loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/model-loader.ts"],"names":["createContextCache","
|
|
1
|
+
{"version":3,"sources":["../src/model-loader.ts"],"names":["createContextCache","isThenable","cacheKey","Plan","setLoaderMappings","setRowFieldMapping","getColumns","inArray","sql","drizzleAdapter","getClient","getSchemaConfig","planFromInfo","ModelLoader","forModel","modelName","builder","columns","model","sqlForModel","values","map","key","columnName","config","columnToTsName","Error","length","getSelection","info","parentType","name","path","rowCache","has","set","forParentRow","context","get","getSelectionForField","typeName","planCache","loadSelection","selection","then","settled","loadWith","played","stageQuery","result","mapping","mappings","loadSelectionForField","returnType","loadFieldWith","play","entry","staged","adapter","canMergeNode","root","mergeNode","models","createResolvablePromise","promise","initLoad","createNode","Map","add","nextTick","client","delete","api","query","findMany","toQuery","where","RAW","table","selectSQL","keys","results","entries","find","row","every","actual","expected","Date","getTime","resolve","reject","err","catch","setTimeout","Set","primaryKey","relations","getPrimaryKey","column","Object","tblColumn","join","getSQL","resolveFn","rejectFn","Promise"],"mappings":";;;;;;;;;;;;;AAAA,SAASA,kBAAkB,EAAEC,UAAU,QAA6C,eAAe;AACnG,SAASC,QAAQ,EAAEC,IAAI,EAAEC,iBAAiB,EAAEC,kBAAkB,QAAQ,2BAA2B;AACjG,SAGEC,UAAU,EACVC,OAAO,EAEPC,GAAG,QAEE,cAAc;AAErB,SAKEC,cAAc,QACT,qBAAqB;AAC5B,SAASC,SAAS,EAAEC,eAAe,QAAwC,oBAAoB;AAC/F,SAASC,YAAY,QAAQ,uBAAuB;AAQpD,OAAO,MAAMC;IAoDX,OAAOC,SACLC,SAAiB,EACjBC,OAA+C,EAC/CC,OAAkB,EAClB;QACA,OAAOjB,mBACL,CAACkB,QAAU,IAAIL,YAAYK,OAAOF,SAAkBD,WAAWE;IAEnE;IAEAE,YAAYD,KAAa,EAAE;QACzB,MAAME,SAAS,IAAI,CAACH,OAAO,CAACI,GAAG,CAAC,CAACC;YAC/B,MAAMC,aAAa,IAAI,CA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AC,EAAE,CAAEsF,MAAM;QACvF;IACF;AAuMF;AAEA,SAASxC;IACP,IAAIyC;IACJ,IAAIC;IACJ,MAAMzC,UAAU,IAAI0C,QAAW,CAAChB,SAASC;QACvCa,YAAYd;QACZe,WAAWd;IACb;IAEA,OAAO;QAAE3B;QAAS0B,SAASc;QAAWb,QAAQc;IAAS;AACzD"}
|
package/esm/schema-builder.js
CHANGED
|
@@ -8,49 +8,42 @@ import { getSchemaConfig } from './utils/config.js';
|
|
|
8
8
|
import { getIDParser, getIDSerializer } from './utils/cursors.js';
|
|
9
9
|
import { getRefFromModel } from './utils/refs.js';
|
|
10
10
|
const schemaBuilderProto = SchemaBuilder.prototype;
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The body of `drizzleObject` and `drizzleInterface`. The two build the same ref, extensions and
|
|
13
|
+
* field builder; only the ref class and which of `objectType`/`interfaceType` registers it differ.
|
|
14
|
+
*/ function defineDrizzleType(builder, table, { select, fields, ...options }, kind) {
|
|
12
15
|
var _ref, _options_variant;
|
|
16
|
+
const isInterface = kind === 'Interface';
|
|
13
17
|
const name = (_ref = (_options_variant = options.variant) !== null && _options_variant !== void 0 ? _options_variant : options.name) !== null && _ref !== void 0 ? _ref : table;
|
|
14
|
-
const ref = options.variant ? new DrizzleObjectRef(options.variant, table) : getRefFromModel(table,
|
|
18
|
+
const ref = options.variant ? isInterface ? new DrizzleInterfaceRef(options.variant, table) : new DrizzleObjectRef(options.variant, table) : getRefFromModel(table, builder, isInterface ? 'interface' : 'object');
|
|
15
19
|
ref.name = name;
|
|
16
|
-
|
|
20
|
+
const config = {
|
|
17
21
|
...options,
|
|
18
22
|
extensions: {
|
|
19
23
|
...options.extensions,
|
|
20
24
|
pothosDrizzleModel: table,
|
|
21
|
-
pothosDrizzleTable: getSchemaConfig(
|
|
25
|
+
pothosDrizzleTable: getSchemaConfig(builder).relations[table],
|
|
22
26
|
pothosDrizzleSelect: typeof select === 'object' ? {
|
|
23
27
|
columns: {},
|
|
24
28
|
...select
|
|
25
29
|
} : select !== null && select !== void 0 ? select : true,
|
|
26
|
-
pothosDrizzleLoader: ModelLoader.forModel(table,
|
|
30
|
+
pothosDrizzleLoader: ModelLoader.forModel(table, builder)
|
|
27
31
|
},
|
|
28
32
|
name,
|
|
29
|
-
fields: fields ? ()=>fields(new DrizzleObjectFieldBuilder(
|
|
30
|
-
}
|
|
33
|
+
fields: fields ? ()=>fields(new DrizzleObjectFieldBuilder(name, builder, table, kind)) : undefined
|
|
34
|
+
};
|
|
35
|
+
if (isInterface) {
|
|
36
|
+
builder.interfaceType(ref, config);
|
|
37
|
+
} else {
|
|
38
|
+
builder.objectType(ref, config);
|
|
39
|
+
}
|
|
31
40
|
return ref;
|
|
41
|
+
}
|
|
42
|
+
schemaBuilderProto.drizzleObject = function drizzleObject(table, options) {
|
|
43
|
+
return defineDrizzleType(this, table, options, 'Object');
|
|
32
44
|
};
|
|
33
|
-
schemaBuilderProto.drizzleInterface = function drizzleInterface(table,
|
|
34
|
-
|
|
35
|
-
const name = (_ref = (_options_variant = options.variant) !== null && _options_variant !== void 0 ? _options_variant : options.name) !== null && _ref !== void 0 ? _ref : table;
|
|
36
|
-
const ref = options.variant ? new DrizzleInterfaceRef(options.variant, table) : getRefFromModel(table, this, 'interface');
|
|
37
|
-
ref.name = name;
|
|
38
|
-
this.interfaceType(ref, {
|
|
39
|
-
...options,
|
|
40
|
-
extensions: {
|
|
41
|
-
...options.extensions,
|
|
42
|
-
pothosDrizzleModel: table,
|
|
43
|
-
pothosDrizzleTable: getSchemaConfig(this).relations[table],
|
|
44
|
-
pothosDrizzleSelect: typeof select === 'object' ? {
|
|
45
|
-
columns: {},
|
|
46
|
-
...select
|
|
47
|
-
} : select !== null && select !== void 0 ? select : true,
|
|
48
|
-
pothosDrizzleLoader: ModelLoader.forModel(table, this)
|
|
49
|
-
},
|
|
50
|
-
name,
|
|
51
|
-
fields: fields ? ()=>fields(new DrizzleObjectFieldBuilder(ref.name, this, table, 'Interface')) : undefined
|
|
52
|
-
});
|
|
53
|
-
return ref;
|
|
45
|
+
schemaBuilderProto.drizzleInterface = function drizzleInterface(table, options) {
|
|
46
|
+
return defineDrizzleType(this, table, options, 'Interface');
|
|
54
47
|
};
|
|
55
48
|
schemaBuilderProto.drizzleNode = function drizzleNode(table, { id: { column, ...idOptions }, name, variant, ...options }) {
|
|
56
49
|
var _ref;
|
|
@@ -63,7 +56,7 @@ schemaBuilderProto.drizzleNode = function drizzleNode(table, { id: { column, ...
|
|
|
63
56
|
];
|
|
64
57
|
const interfaceRef = (_this_nodeInterfaceRef = (_this = this).nodeInterfaceRef) === null || _this_nodeInterfaceRef === void 0 ? void 0 : _this_nodeInterfaceRef.call(_this);
|
|
65
58
|
const resolve = getIDSerializer(idColumns, schemaConfig);
|
|
66
|
-
const idParser = getIDParser(idColumns);
|
|
59
|
+
const idParser = getIDParser(idColumns, schemaConfig);
|
|
67
60
|
const typeName = (_ref = variant !== null && variant !== void 0 ? variant : name) !== null && _ref !== void 0 ? _ref : table;
|
|
68
61
|
const nodeRef = new DrizzleNodeRef(typeName, table, {
|
|
69
62
|
parseId: (id)=>{
|
|
@@ -117,132 +110,30 @@ schemaBuilderProto.drizzleNode = function drizzleNode(table, { id: { column, ...
|
|
|
117
110
|
this.configStore.associateParamWithRef(nodeRef, ref);
|
|
118
111
|
return nodeRef;
|
|
119
112
|
};
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
113
|
+
/**
|
|
114
|
+
* The body of `drizzleObjectField(s)` and `drizzleInterfaceField(s)`: they differ only in kind.
|
|
115
|
+
* A table name names the interface registered under it, as `drizzleInterface` registers one.
|
|
116
|
+
*/ function addDrizzleFields(builder, type, fields, graphqlKind) {
|
|
117
|
+
const ref = typeof type === 'string' ? getRefFromModel(type, builder, graphqlKind ? 'interface' : 'object') : type;
|
|
118
|
+
builder.configStore.onTypeConfig(ref, ({ name })=>{
|
|
119
|
+
builder.configStore.addFields(ref, ()=>fields(new DrizzleObjectFieldBuilder(name, builder, ref.tableName, graphqlKind)));
|
|
126
120
|
});
|
|
121
|
+
}
|
|
122
|
+
schemaBuilderProto.drizzleObjectField = function drizzleObjectField(type, fieldName, field) {
|
|
123
|
+
addDrizzleFields(this, type, (t)=>({
|
|
124
|
+
[fieldName]: field(t)
|
|
125
|
+
}));
|
|
127
126
|
};
|
|
128
127
|
schemaBuilderProto.drizzleInterfaceField = function drizzleInterfaceField(type, fieldName, field) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
[fieldName]: field(new DrizzleObjectFieldBuilder(name, this, ref.tableName, 'Interface'))
|
|
133
|
-
}));
|
|
134
|
-
});
|
|
128
|
+
addDrizzleFields(this, type, (t)=>({
|
|
129
|
+
[fieldName]: field(t)
|
|
130
|
+
}), 'Interface');
|
|
135
131
|
};
|
|
136
132
|
schemaBuilderProto.drizzleObjectFields = function drizzleObjectFields(type, fields) {
|
|
137
|
-
|
|
138
|
-
this.configStore.onTypeConfig(ref, ({ name })=>{
|
|
139
|
-
this.configStore.addFields(ref, ()=>fields(new DrizzleObjectFieldBuilder(name, this, ref.tableName)));
|
|
140
|
-
});
|
|
133
|
+
addDrizzleFields(this, type, fields);
|
|
141
134
|
};
|
|
142
135
|
schemaBuilderProto.drizzleInterfaceFields = function drizzleInterfaceFields(type, fields) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
this.configStore.addFields(ref, ()=>fields(new DrizzleObjectFieldBuilder(name, this, ref.tableName, 'Interface')));
|
|
146
|
-
});
|
|
147
|
-
}; // schemaBuilderProto.drizzleGraphQLOrderBy = function drizzleGraphQLOrderBy(
|
|
148
|
-
// this: PothosSchemaTypes.SchemaBuilder<SchemaTypes>,
|
|
149
|
-
// table: string,
|
|
150
|
-
// type: GraphQLInputObjectType,
|
|
151
|
-
// options?: { extensions?: object },
|
|
152
|
-
// ) {
|
|
153
|
-
// return (
|
|
154
|
-
// this as typeof this & {
|
|
155
|
-
// addGraphQLInput: (
|
|
156
|
-
// type: GraphQLInputObjectType,
|
|
157
|
-
// options: Record<string, unknown>,
|
|
158
|
-
// ) => InputObjectRef<SchemaTypes, {}>;
|
|
159
|
-
// }
|
|
160
|
-
// ).addGraphQLInput(type, {
|
|
161
|
-
// ...options,
|
|
162
|
-
// extensions: {
|
|
163
|
-
// ...options?.extensions,
|
|
164
|
-
// drizzleGraphQL: {
|
|
165
|
-
// inputType: 'orderBy',
|
|
166
|
-
// table,
|
|
167
|
-
// tableConfig: getSchemaConfig(this).relations[table],
|
|
168
|
-
// } satisfies DrizzleGraphQLInputExtensions,
|
|
169
|
-
// },
|
|
170
|
-
// });
|
|
171
|
-
// } as never;
|
|
172
|
-
// schemaBuilderProto.drizzleGraphQLFilters = function drizzleGraphQLFilters(
|
|
173
|
-
// this: PothosSchemaTypes.SchemaBuilder<SchemaTypes>,
|
|
174
|
-
// table: string,
|
|
175
|
-
// type: GraphQLInputObjectType,
|
|
176
|
-
// options?: { extensions?: object },
|
|
177
|
-
// ) {
|
|
178
|
-
// return (
|
|
179
|
-
// this as typeof this & {
|
|
180
|
-
// addGraphQLInput: (
|
|
181
|
-
// type: GraphQLInputObjectType,
|
|
182
|
-
// options: Record<string, unknown>,
|
|
183
|
-
// ) => InputObjectRef<SchemaTypes, {}>;
|
|
184
|
-
// }
|
|
185
|
-
// ).addGraphQLInput(type, {
|
|
186
|
-
// ...options,
|
|
187
|
-
// extensions: {
|
|
188
|
-
// ...options?.extensions,
|
|
189
|
-
// drizzleGraphQL: {
|
|
190
|
-
// inputType: 'filters',
|
|
191
|
-
// table,
|
|
192
|
-
// tableConfig: getSchemaConfig(this).relations[table],
|
|
193
|
-
// } satisfies DrizzleGraphQLInputExtensions,
|
|
194
|
-
// },
|
|
195
|
-
// });
|
|
196
|
-
// } as never;
|
|
197
|
-
// schemaBuilderProto.drizzleGraphQLInsert = function drizzleGraphQLInsert(
|
|
198
|
-
// this: PothosSchemaTypes.SchemaBuilder<SchemaTypes>,
|
|
199
|
-
// table: string,
|
|
200
|
-
// type: GraphQLInputObjectType,
|
|
201
|
-
// options?: { extensions?: object },
|
|
202
|
-
// ) {
|
|
203
|
-
// return (
|
|
204
|
-
// this as typeof this & {
|
|
205
|
-
// addGraphQLInput: (
|
|
206
|
-
// type: GraphQLInputObjectType,
|
|
207
|
-
// options: Record<string, unknown>,
|
|
208
|
-
// ) => InputObjectRef<SchemaTypes, {}>;
|
|
209
|
-
// }
|
|
210
|
-
// ).addGraphQLInput(type, {
|
|
211
|
-
// ...options,
|
|
212
|
-
// extensions: {
|
|
213
|
-
// ...options?.extensions,
|
|
214
|
-
// drizzleGraphQL: {
|
|
215
|
-
// inputType: 'insert',
|
|
216
|
-
// table,
|
|
217
|
-
// tableConfig: getSchemaConfig(this).relations[table],
|
|
218
|
-
// } satisfies DrizzleGraphQLInputExtensions,
|
|
219
|
-
// },
|
|
220
|
-
// });
|
|
221
|
-
// } as never;
|
|
222
|
-
// schemaBuilderProto.drizzleGraphQLUpdate = function drizzleGraphQLUpdate(
|
|
223
|
-
// this: PothosSchemaTypes.SchemaBuilder<SchemaTypes>,
|
|
224
|
-
// table: string,
|
|
225
|
-
// type: GraphQLInputObjectType,
|
|
226
|
-
// options?: { extensions?: object },
|
|
227
|
-
// ) {
|
|
228
|
-
// return (
|
|
229
|
-
// this as typeof this & {
|
|
230
|
-
// addGraphQLInput: (
|
|
231
|
-
// type: GraphQLInputObjectType,
|
|
232
|
-
// options: Record<string, unknown>,
|
|
233
|
-
// ) => InputObjectRef<SchemaTypes, {}>;
|
|
234
|
-
// }
|
|
235
|
-
// ).addGraphQLInput(type, {
|
|
236
|
-
// ...options,
|
|
237
|
-
// extensions: {
|
|
238
|
-
// ...options?.extensions,
|
|
239
|
-
// drizzleGraphQL: {
|
|
240
|
-
// inputType: 'update',
|
|
241
|
-
// table,
|
|
242
|
-
// tableConfig: getSchemaConfig(this).relations[table],
|
|
243
|
-
// } satisfies DrizzleGraphQLInputExtensions,
|
|
244
|
-
// },
|
|
245
|
-
// });
|
|
246
|
-
// } as never;
|
|
136
|
+
addDrizzleFields(this, type, fields, 'Interface');
|
|
137
|
+
};
|
|
247
138
|
|
|
248
139
|
//# sourceMappingURL=schema-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schema-builder.ts"],"names":["SchemaBuilder","brandWithType","completeValue","PothosError","DrizzleObjectFieldBuilder","DrizzleInterfaceRef","ModelLoader","DrizzleNodeRef","DrizzleObjectRef","getSchemaConfig","getIDParser","getIDSerializer","getRefFromModel","schemaBuilderProto","prototype","
|
|
1
|
+
{"version":3,"sources":["../src/schema-builder.ts"],"names":["SchemaBuilder","brandWithType","completeValue","PothosError","DrizzleObjectFieldBuilder","DrizzleInterfaceRef","ModelLoader","DrizzleNodeRef","DrizzleObjectRef","getSchemaConfig","getIDParser","getIDSerializer","getRefFromModel","schemaBuilderProto","prototype","defineDrizzleType","builder","table","select","fields","options","kind","isInterface","name","variant","ref","config","extensions","pothosDrizzleModel","pothosDrizzleTable","relations","pothosDrizzleSelect","columns","pothosDrizzleLoader","forModel","undefined","interfaceType","objectType","drizzleObject","drizzleInterface","drizzleNode","id","column","idOptions","schemaConfig","tableConfig","idColumn","idColumns","Array","isArray","interfaceRef","nodeInterfaceRef","resolve","idParser","typeName","nodeRef","parseId","parsed","columnToTsName","modelLoader","extendedOptions","interfaces","loadWithoutCache","context","info","record","loadSelectionForField","addInterfaces","configStore","onTypeConfig","nodeConfig","objectField","relay","idFieldName","t","globalID","idFieldOptions","nullable","args","parent","type","associateParamWithRef","addDrizzleFields","graphqlKind","addFields","tableName","drizzleObjectField","fieldName","field","drizzleInterfaceField","drizzleObjectFields","drizzleInterfaceFields"],"mappings":"AAAA,OAAOA,iBACLC,aAAa,EACbC,aAAa,EAKbC,WAAW,QAEN,eAAe;AAGtB,SAASC,yBAAyB,QAAQ,6BAA6B;AACvE,SAASC,mBAAmB,QAAQ,qBAAqB;AACzD,SAASC,WA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