@pothos/plugin-drizzle 0.18.1 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/CHANGELOG.md +357 -0
  2. package/README.md +1199 -563
  3. package/dts/connection-helpers.d.ts +18 -8
  4. package/dts/connection-helpers.d.ts.map +1 -1
  5. package/dts/drizzle-field-builder.d.ts +4 -11
  6. package/dts/drizzle-field-builder.d.ts.map +1 -1
  7. package/dts/global-types.d.ts.map +1 -1
  8. package/dts/index.d.ts.map +1 -1
  9. package/dts/model-loader.d.ts +18 -17
  10. package/dts/model-loader.d.ts.map +1 -1
  11. package/dts/types.d.ts +82 -22
  12. package/dts/types.d.ts.map +1 -1
  13. package/dts/utils/adapter.d.ts +39 -0
  14. package/dts/utils/adapter.d.ts.map +1 -0
  15. package/dts/utils/await-selections.d.ts +12 -0
  16. package/dts/utils/await-selections.d.ts.map +1 -0
  17. package/dts/utils/config.d.ts +23 -3
  18. package/dts/utils/config.d.ts.map +1 -1
  19. package/dts/utils/cursors.d.ts +6 -6
  20. package/dts/utils/cursors.d.ts.map +1 -1
  21. package/dts/utils/map-query.d.ts +22 -21
  22. package/dts/utils/map-query.d.ts.map +1 -1
  23. package/dts/utils/path-info.d.ts +13 -0
  24. package/dts/utils/path-info.d.ts.map +1 -0
  25. package/dts/utils/relation-filter.d.ts +48 -0
  26. package/dts/utils/relation-filter.d.ts.map +1 -0
  27. package/dts/utils/selections.d.ts +2 -21
  28. package/dts/utils/selections.d.ts.map +1 -1
  29. package/esm/connection-helpers.d.ts +18 -8
  30. package/esm/connection-helpers.d.ts.map +1 -1
  31. package/esm/connection-helpers.js +52 -19
  32. package/esm/connection-helpers.js.map +1 -1
  33. package/esm/drizzle-field-builder.d.ts +4 -11
  34. package/esm/drizzle-field-builder.d.ts.map +1 -1
  35. package/esm/drizzle-field-builder.js +138 -96
  36. package/esm/drizzle-field-builder.js.map +1 -1
  37. package/esm/field-builder.js +61 -47
  38. package/esm/field-builder.js.map +1 -1
  39. package/esm/global-types.d.ts.map +1 -1
  40. package/esm/index.d.ts.map +1 -1
  41. package/esm/index.js +37 -61
  42. package/esm/index.js.map +1 -1
  43. package/esm/model-loader.d.ts +18 -17
  44. package/esm/model-loader.d.ts.map +1 -1
  45. package/esm/model-loader.js +76 -45
  46. package/esm/model-loader.js.map +1 -1
  47. package/esm/schema-builder.js +40 -149
  48. package/esm/schema-builder.js.map +1 -1
  49. package/esm/types.d.ts +82 -22
  50. package/esm/types.d.ts.map +1 -1
  51. package/esm/types.js.map +1 -1
  52. package/esm/utils/adapter.d.ts +39 -0
  53. package/esm/utils/adapter.d.ts.map +1 -0
  54. package/esm/utils/adapter.js +137 -0
  55. package/esm/utils/adapter.js.map +1 -0
  56. package/esm/utils/await-selections.d.ts +12 -0
  57. package/esm/utils/await-selections.d.ts.map +1 -0
  58. package/esm/utils/await-selections.js +19 -0
  59. package/esm/utils/await-selections.js.map +1 -0
  60. package/esm/utils/config.d.ts +23 -3
  61. package/esm/utils/config.d.ts.map +1 -1
  62. package/esm/utils/config.js +1 -4
  63. package/esm/utils/config.js.map +1 -1
  64. package/esm/utils/cursors.d.ts +6 -6
  65. package/esm/utils/cursors.d.ts.map +1 -1
  66. package/esm/utils/cursors.js +75 -92
  67. package/esm/utils/cursors.js.map +1 -1
  68. package/esm/utils/map-query.d.ts +22 -21
  69. package/esm/utils/map-query.d.ts.map +1 -1
  70. package/esm/utils/map-query.js +40 -354
  71. package/esm/utils/map-query.js.map +1 -1
  72. package/esm/utils/path-info.d.ts +13 -0
  73. package/esm/utils/path-info.d.ts.map +1 -0
  74. package/esm/utils/path-info.js +37 -0
  75. package/esm/utils/path-info.js.map +1 -0
  76. package/esm/utils/relation-filter.d.ts +48 -0
  77. package/esm/utils/relation-filter.d.ts.map +1 -0
  78. package/esm/utils/relation-filter.js +92 -0
  79. package/esm/utils/relation-filter.js.map +1 -0
  80. package/esm/utils/selections.d.ts +2 -21
  81. package/esm/utils/selections.d.ts.map +1 -1
  82. package/esm/utils/selections.js +1 -133
  83. package/esm/utils/selections.js.map +1 -1
  84. package/lib/connection-helpers.js +51 -18
  85. package/lib/connection-helpers.js.map +1 -1
  86. package/lib/drizzle-field-builder.js +136 -94
  87. package/lib/drizzle-field-builder.js.map +1 -1
  88. package/lib/field-builder.js +58 -44
  89. package/lib/field-builder.js.map +1 -1
  90. package/lib/index.js +36 -60
  91. package/lib/index.js.map +1 -1
  92. package/lib/model-loader.js +76 -45
  93. package/lib/model-loader.js.map +1 -1
  94. package/lib/schema-builder.js +40 -149
  95. package/lib/schema-builder.js.map +1 -1
  96. package/lib/types.js.map +1 -1
  97. package/lib/utils/adapter.js +147 -0
  98. package/lib/utils/adapter.js.map +1 -0
  99. package/lib/utils/await-selections.js +20 -0
  100. package/lib/utils/await-selections.js.map +1 -0
  101. package/lib/utils/config.js +1 -4
  102. package/lib/utils/config.js.map +1 -1
  103. package/lib/utils/cursors.js +67 -90
  104. package/lib/utils/cursors.js.map +1 -1
  105. package/lib/utils/map-query.js +28 -359
  106. package/lib/utils/map-query.js.map +1 -1
  107. package/lib/utils/path-info.js +39 -0
  108. package/lib/utils/path-info.js.map +1 -0
  109. package/lib/utils/relation-filter.js +91 -0
  110. package/lib/utils/relation-filter.js.map +1 -0
  111. package/lib/utils/selections.js +3 -158
  112. package/lib/utils/selections.js.map +1 -1
  113. package/package.json +10 -8
  114. package/src/connection-helpers.ts +168 -54
  115. package/src/drizzle-field-builder.ts +296 -176
  116. package/src/field-builder.ts +110 -77
  117. package/src/global-types.ts +0 -32
  118. package/src/index.ts +42 -68
  119. package/src/model-loader.ts +110 -71
  120. package/src/schema-builder.ts +76 -169
  121. package/src/types.ts +178 -46
  122. package/src/utils/adapter.ts +197 -0
  123. package/src/utils/await-selections.ts +31 -0
  124. package/src/utils/config.ts +1 -5
  125. package/src/utils/cursors.ts +84 -83
  126. package/src/utils/map-query.ts +51 -734
  127. package/src/utils/path-info.ts +40 -0
  128. package/src/utils/relation-filter.ts +185 -0
  129. package/src/utils/selections.ts +2 -207
  130. package/dts/utils/deep-equal.d.ts +0 -2
  131. package/dts/utils/deep-equal.d.ts.map +0 -1
  132. package/dts/utils/drizzle-graphql.d.ts +0 -2
  133. package/dts/utils/drizzle-graphql.d.ts.map +0 -1
  134. package/dts/utils/loader-map.d.ts +0 -11
  135. package/dts/utils/loader-map.d.ts.map +0 -1
  136. package/dts/utils/usage.d.ts +0 -5
  137. package/dts/utils/usage.d.ts.map +0 -1
  138. package/esm/utils/deep-equal.d.ts +0 -2
  139. package/esm/utils/deep-equal.d.ts.map +0 -1
  140. package/esm/utils/deep-equal.js +0 -45
  141. package/esm/utils/deep-equal.js.map +0 -1
  142. package/esm/utils/drizzle-graphql.d.ts +0 -2
  143. package/esm/utils/drizzle-graphql.d.ts.map +0 -1
  144. package/esm/utils/drizzle-graphql.js +0 -232
  145. package/esm/utils/drizzle-graphql.js.map +0 -1
  146. package/esm/utils/loader-map.d.ts +0 -11
  147. package/esm/utils/loader-map.d.ts.map +0 -1
  148. package/esm/utils/loader-map.js +0 -35
  149. package/esm/utils/loader-map.js.map +0 -1
  150. package/esm/utils/usage.d.ts +0 -5
  151. package/esm/utils/usage.d.ts.map +0 -1
  152. package/esm/utils/usage.js +0 -59
  153. package/esm/utils/usage.js.map +0 -1
  154. package/lib/utils/deep-equal.js +0 -55
  155. package/lib/utils/deep-equal.js.map +0 -1
  156. package/lib/utils/drizzle-graphql.js +0 -236
  157. package/lib/utils/drizzle-graphql.js.map +0 -1
  158. package/lib/utils/loader-map.js +0 -56
  159. package/lib/utils/loader-map.js.map +0 -1
  160. package/lib/utils/usage.js +0 -83
  161. package/lib/utils/usage.js.map +0 -1
  162. package/src/utils/deep-equal.ts +0 -57
  163. package/src/utils/drizzle-graphql.ts +0 -274
  164. package/src/utils/loader-map.ts +0 -49
  165. package/src/utils/usage.ts +0 -62
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/drizzle-graphql.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;CAChE,iBAAiB;CACjB,UAAU;CACV,uBAAuB;CACvB,0BAA0B;CAC1B,oDAAoD;CACpD,iBAAiB;CACjB,iBAAiB;CACjB,uEAAuE;CACvE,QAAQ;CACR,MAAM;CAEN,qGAAqG;CACrG,KAAK;CAEL,wEAAwE;CACxE,mBAAmB;CACnB,uBAAuB;CACvB,yCAAyC;CACzC,sCAAsC;CACtC,OAAO;CACP,0BAA0B;CAC1B,+BAA+B;CAC/B,+DAA+D;CAC/D,yBAAyB;CACzB,MAAM;CAEN,6CAA6C;CAC7C,2BAA2B;CAC3B,cAAc;CACd,MAAM;CAEN,sBAAsB;CACtB,gCAAgC;CAChC,gCAAgC;CAChC,uFAAuF;CACvF,WAAW;CACX,QAAQ;CAER,oCAAoC;CAEpC,0CAA0C;CAC1C,qEAAqE;CACrE,yBAAyB;CACzB,oCAAoC;CACpC,UAAU;CACV,QAAQ;CAER,sGAAsG;CACtG,MAAM;CAEN,kCAAkC;CAClC,qDAAqD;CACrD,gCAAgC;CAChC,kBAAkB;CAClB,QAAQ;CAER,iDAAiD;CACjD,qBAAqB;CACrB,mGAAmG;CACnG,SAAS;CACT,MAAM;CAEN,qGAAqG;CACrG,KAAK"}
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get cacheKey () {
13
- return cacheKey;
14
- },
15
- get getLoaderMapping () {
16
- return getLoaderMapping;
17
- },
18
- get setLoaderMappings () {
19
- return setLoaderMappings;
20
- }
21
- });
22
- const _core = require("@pothos/core");
23
- const cache = (0, _core.createContextCache)(()=>new Map());
24
- function cacheKey(type, path, subPath = []) {
25
- let key = '';
26
- let current = path;
27
- while(current){
28
- if (typeof current.key === 'string') {
29
- key = key ? `${current.key}.${key}` : current.key;
30
- }
31
- current = current.prev;
32
- }
33
- for (const entry of subPath){
34
- key = `${key}.${entry}`;
35
- }
36
- return `${type}@${key}`;
37
- }
38
- function setLoaderMappings(ctx, info, value) {
39
- const map = cache(ctx);
40
- for (const [field, mapping] of Object.entries(value)){
41
- const subPath = [
42
- ...mapping.indirectPath,
43
- field
44
- ];
45
- const key = cacheKey(mapping.type, info.path, subPath);
46
- map.set(key, mapping.mappings);
47
- }
48
- }
49
- function getLoaderMapping(ctx, path, type) {
50
- var _map_get;
51
- const map = cache(ctx);
52
- const key = cacheKey(type, path, []);
53
- return (_map_get = map.get(key)) !== null && _map_get !== void 0 ? _map_get : null;
54
- }
55
-
56
- //# sourceMappingURL=loader-map.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/loader-map.ts"],"names":["cacheKey","getLoaderMapping","setLoaderMappings","cache","createContextCache","Map","type","path","subPath","key","current","prev","entry","ctx","info","value","map","field","mapping","Object","entries","indirectPath","set","mappings","get"],"mappings":";;;;;;;;;;;QAegBA;eAAAA;;QA4BAC;eAAAA;;QAVAC;eAAAA;;;sBAjCmB;AAanC,MAAMC,QAAQC,IAAAA,wBAAkB,EAAC,IAAM,IAAIC;AAEpC,SAASL,SAASM,IAAY,EAAEC,IAAgC,EAAEC,UAAoB,EAAE;IAC7F,IAAIC,MAAM;IACV,IAAIC,UAAkDH;IAEtD,MAAOG,QAAS;QACd,IAAI,OAAOA,QAAQD,GAAG,KAAK,UAAU;YACnCA,MAAMA,MAAM,GAAGC,QAAQD,GAAG,CAAC,CAAC,EAAEA,KAAK,GAAGC,QAAQD,GAAG;QACnD;QACAC,UAAUA,QAAQC,IAAI;IACxB;IAEA,KAAK,MAAMC,SAASJ,QAAS;QAC3BC,MAAM,GAAGA,IAAI,CAAC,EAAEG,OAAO;IACzB;IAEA,OAAO,GAAGN,KAAK,CAAC,EAAEG,KAAK;AACzB;AAEO,SAASP,kBAAkBW,GAAW,EAAEC,IAAwB,EAAEC,KAAqB;IAC5F,MAAMC,MAAMb,MAAMU;IAClB,KAAK,MAAM,CAACI,OAAOC,QAAQ,IAAIC,OAAOC,OAAO,CAACL,OAAQ;QACpD,MAAMP,UAAU;eAAIU,QAAQG,YAAY;YAAEJ;SAAM;QAChD,MAAMR,MAAMT,SAASkB,QAAQZ,IAAI,EAAEQ,KAAKP,IAAI,EAAEC;QAE9CQ,IAAIM,GAAG,CAACb,KAAKS,QAAQK,QAAQ;IAC/B;AACF;AAEO,SAAStB,iBAAiBY,GAAW,EAAEN,IAAgC,EAAED,IAAY;QAInFU;IAHP,MAAMA,MAAMb,MAAMU;IAClB,MAAMJ,MAAMT,SAASM,MAAMC,MAAM,EAAE;IAEnC,QAAOS,WAAAA,IAAIQ,GAAG,CAACf,kBAARO,sBAAAA,WAAgB;AACzB"}
@@ -1,83 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get extendWithUsage () {
13
- return extendWithUsage;
14
- },
15
- get isUsed () {
16
- return isUsed;
17
- },
18
- get usageSymbol () {
19
- return usageSymbol;
20
- },
21
- get wrapWithUsageCheck () {
22
- return wrapWithUsageCheck;
23
- }
24
- });
25
- const usageSymbol = Symbol.for('Pothos.isUsed');
26
- function wrapWithUsageCheck(obj) {
27
- const result = {};
28
- let used = true;
29
- Object.defineProperty(result, usageSymbol, {
30
- get () {
31
- return used;
32
- },
33
- set (value) {
34
- used = value;
35
- },
36
- enumerable: false
37
- });
38
- for (const key of Object.keys(obj)){
39
- // only set to false if the object has keys
40
- used = false;
41
- Object.defineProperty(result, key, {
42
- enumerable: true,
43
- configurable: true,
44
- get () {
45
- used = true;
46
- return obj[key];
47
- }
48
- });
49
- }
50
- return result;
51
- }
52
- function isUsed(obj) {
53
- return !(usageSymbol in obj) || obj[usageSymbol];
54
- }
55
- function extendWithUsage(original, extension) {
56
- if (!(usageSymbol in original)) {
57
- return {
58
- ...original,
59
- ...extension
60
- };
61
- }
62
- const result = {
63
- ...extension
64
- };
65
- for (const key of [
66
- usageSymbol,
67
- ...Object.keys(original)
68
- ]){
69
- if (key in result) {
70
- continue;
71
- }
72
- Object.defineProperty(result, key, {
73
- enumerable: key !== usageSymbol,
74
- configurable: key !== usageSymbol,
75
- get () {
76
- return original[key];
77
- }
78
- });
79
- }
80
- return result;
81
- }
82
-
83
- //# sourceMappingURL=usage.js.map
@@ -1 +0,0 @@
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":";;;;;;;;;;;QAoCgBA;eAAAA;;QAJAC;eAAAA;;QAhCHC;eAAAA;;QAEGC;eAAAA;;;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"}
@@ -1,57 +0,0 @@
1
- export function deepEqual(left: unknown, right: unknown, ignore?: Set<string>) {
2
- if (left === right) {
3
- return true;
4
- }
5
-
6
- if (left && right && typeof left === 'object' && typeof right === 'object') {
7
- if (Array.isArray(left)) {
8
- if (!Array.isArray(right)) {
9
- return false;
10
- }
11
-
12
- const { length } = left;
13
-
14
- if (right.length !== length) {
15
- return false;
16
- }
17
-
18
- for (let i = 0; i < length; i += 1) {
19
- if (!deepEqual(left[i], right[i])) {
20
- return false;
21
- }
22
- }
23
-
24
- return true;
25
- }
26
-
27
- const lValue = left.valueOf?.();
28
- const rValue = right.valueOf?.();
29
-
30
- if ((lValue != null || rValue != null) && typeof lValue !== 'object') {
31
- return lValue === rValue;
32
- }
33
-
34
- const keys = Object.keys(left);
35
- const keyLength = keys.length;
36
-
37
- if (keyLength !== Object.keys(right).length) {
38
- return false;
39
- }
40
-
41
- for (const key of keys) {
42
- if (ignore?.has(key)) {
43
- continue;
44
- }
45
-
46
- if (
47
- !deepEqual((left as Record<string, unknown>)[key], (right as Record<string, unknown>)[key])
48
- ) {
49
- return false;
50
- }
51
- }
52
-
53
- return true;
54
- }
55
-
56
- return false;
57
- }
@@ -1,274 +0,0 @@
1
- export {};
2
- // import {
3
- // type Column,
4
- // type SQL,
5
- // type TableRelationalConfig,
6
- // asc,
7
- // desc,
8
- // operators as ops,
9
- // } from 'drizzle-orm';
10
- // import { GraphQLError } from 'graphql';
11
-
12
- // // biome-ignore lint/suspicious/noExplicitAny: this is fine
13
- // export const remapFromGraphQLCore = (value: any, column: Column, columnName: string) => {
14
- // switch (column.dataType) {
15
- // case 'date': {
16
- // const formatted = new Date(value);
17
- // if (Number.isNaN(formatted.getTime())) {
18
- // throw new GraphQLError(`Field '${columnName}' is not a valid date!`);
19
- // }
20
-
21
- // return formatted;
22
- // }
23
-
24
- // case 'buffer': {
25
- // if (!Array.isArray(value)) {
26
- // throw new GraphQLError(`Field '${columnName}' is not an array!`);
27
- // }
28
-
29
- // return Buffer.from(value);
30
- // }
31
-
32
- // case 'json': {
33
- // if (column.columnType === 'PgGeometryObject') {
34
- // return value;
35
- // }
36
-
37
- // try {
38
- // return JSON.parse(value);
39
- // } catch (e) {
40
- // throw new GraphQLError(
41
- // `Invalid JSON in field '${columnName}':\n${e instanceof Error ? e.message : 'Unknown error'}`,
42
- // );
43
- // }
44
- // }
45
-
46
- // case 'array': {
47
- // if (!Array.isArray(value)) {
48
- // throw new GraphQLError(`Field '${columnName}' is not an array!`);
49
- // }
50
-
51
- // if (column.columnType === 'PgGeometry' && value.length !== 2) {
52
- // throw new GraphQLError(
53
- // `Invalid float tuple in field '${columnName}': expected array with length of 2, received ${value.length}`,
54
- // );
55
- // }
56
-
57
- // return value;
58
- // }
59
-
60
- // case 'bigint': {
61
- // try {
62
- // return BigInt(value);
63
- // } catch (_error) {
64
- // throw new GraphQLError(`Field '${columnName}' is not a BigInt!`);
65
- // }
66
- // }
67
-
68
- // default: {
69
- // return value;
70
- // }
71
- // }
72
- // };
73
-
74
- // export const remapFromGraphQLSingleInput = (
75
- // // biome-ignore lint/suspicious/noExplicitAny: this is fine
76
- // queryInput: Record<string, any>,
77
- // table: TableRelationalConfig,
78
- // ) => {
79
- // for (const [key, value] of Object.entries(queryInput)) {
80
- // if (value === undefined) {
81
- // delete queryInput[key];
82
- // } else {
83
- // const column = table.columns[key];
84
- // if (!column) {
85
- // throw new GraphQLError(`Unknown column: ${key}`);
86
- // }
87
-
88
- // if (value === null && (column as Column).notNull) {
89
- // delete queryInput[key];
90
- // continue;
91
- // }
92
-
93
- // queryInput[key] = remapFromGraphQLCore(value, column as Column, key);
94
- // }
95
- // }
96
-
97
- // return queryInput;
98
- // };
99
-
100
- // export const remapFromGraphQLArrayInput = (
101
- // // biome-ignore lint/suspicious/noExplicitAny: this is fine
102
- // queryInput: Record<string, any>[],
103
- // table: TableRelationalConfig,
104
- // ) => {
105
- // for (const entry of queryInput) {
106
- // remapFromGraphQLSingleInput(entry, table);
107
- // }
108
-
109
- // return queryInput;
110
- // };
111
-
112
- // export type OrderByArgs<TTable extends TableRelationalConfig> = {
113
- // [Key in keyof TTable['columns']]?: {
114
- // direction: 'asc' | 'desc';
115
- // priority: number;
116
- // };
117
- // };
118
-
119
- // export const extractOrderBy = <
120
- // TTable extends TableRelationalConfig,
121
- // // biome-ignore lint/suspicious/noExplicitAny: this is fine
122
- // TArgs extends OrderByArgs<any> = OrderByArgs<TTable>,
123
- // >(
124
- // table: TTable,
125
- // orderArgs: TArgs,
126
- // ): SQL[] => {
127
- // const res = [] as SQL[];
128
-
129
- // for (const [column, config] of Object.entries(orderArgs).sort(
130
- // (a, b) => (b[1]?.priority ?? 0) - (a[1]?.priority ?? 0),
131
- // )) {
132
- // if (!config) {
133
- // continue;
134
- // }
135
- // const { direction } = config;
136
-
137
- // res.push(direction === 'asc' ? asc(table.columns[column]!) : desc(table.columns[column]!));
138
- // }
139
-
140
- // return res;
141
- // };
142
-
143
- // export const extractFiltersColumn = <TColumn extends Column>(
144
- // column: TColumn,
145
- // columnName: string,
146
- // operators: Record<string, unknown> & { OR?: Record<string, unknown>[] },
147
- // ): SQL | undefined => {
148
- // if (!operators.OR?.length) {
149
- // // biome-ignore lint/performance/noDelete: <explanation>
150
- // delete operators.OR;
151
- // }
152
-
153
- // const entries = Object.entries(operators);
154
-
155
- // if (operators.OR) {
156
- // if (entries.length > 1) {
157
- // throw new GraphQLError(
158
- // `WHERE ${columnName}: Cannot specify both fields and 'OR' in column operators!`,
159
- // );
160
- // }
161
-
162
- // const variants = [] as SQL[];
163
-
164
- // for (const variant of operators.OR) {
165
- // const extracted = extractFiltersColumn(column, columnName, variant);
166
-
167
- // // biome-ignore lint/style/useBlockStatements: <explanation>
168
- // if (extracted) variants.push(extracted);
169
- // }
170
-
171
- // return variants.length ? (variants.length > 1 ? ops.or(...variants) : variants[0]) : undefined;
172
- // }
173
-
174
- // const variants = [] as SQL[];
175
- // for (const [operatorName, operatorValue] of entries) {
176
- // // biome-ignore lint/style/useBlockStatements: <explanation>
177
- // if (operatorValue === null || operatorValue === false) continue;
178
-
179
- // switch (operatorName) {
180
- // case 'eq':
181
- // case 'ne':
182
- // case 'gt':
183
- // case 'gte':
184
- // case 'lt':
185
- // case 'lte': {
186
- // const singleValue = remapFromGraphQLCore(operatorValue, column, columnName);
187
- // variants.push(ops[operatorName](column, singleValue));
188
-
189
- // break;
190
- // }
191
- // case 'like':
192
- // case 'notLike':
193
- // case 'ilike':
194
- // case 'notIlike':
195
- // variants.push(ops[operatorName](column, operatorValue as string));
196
- // break;
197
- // case 'inArray':
198
- // case 'notInArray': {
199
- // // biome-ignore lint/suspicious/noExplicitAny: this is fine
200
- // if (!(operatorValue as any[]).length) {
201
- // throw new GraphQLError(
202
- // `WHERE ${columnName}: Unable to use operator ${operatorName} with an empty array!`,
203
- // );
204
- // }
205
- // // biome-ignore lint/suspicious/noExplicitAny: this is fine
206
- // const arrayValue = (operatorValue as any[]).map((val) =>
207
- // remapFromGraphQLCore(val, column, columnName),
208
- // );
209
-
210
- // variants.push(ops[operatorName](column, arrayValue));
211
- // break;
212
- // }
213
- // case 'isNull':
214
- // case 'isNotNull':
215
- // variants.push(ops[operatorName](column));
216
- // break;
217
- // default:
218
- // throw new GraphQLError(`Unknown operator: ${operatorName}`);
219
- // }
220
- // }
221
-
222
- // return variants.length ? (variants.length > 1 ? ops.and(...variants) : variants[0]) : undefined;
223
- // };
224
-
225
- // export const extractFilters = <TTable extends TableRelationalConfig>(
226
- // table: TTable,
227
- // tableName: string,
228
- // filters: Record<string, unknown> & {
229
- // OR?: Record<string, unknown>[];
230
- // },
231
- // ): SQL | undefined => {
232
- // if (!filters.OR?.length) {
233
- // // biome-ignore lint/performance/noDelete: <explanation>
234
- // delete filters.OR;
235
- // }
236
-
237
- // const entries = Object.entries(filters);
238
- // if (!entries.length) {
239
- // return;
240
- // }
241
-
242
- // if (filters.OR) {
243
- // if (entries.length > 1) {
244
- // throw new GraphQLError(
245
- // `WHERE ${tableName}: Cannot specify both fields and 'OR' in table filters!`,
246
- // );
247
- // }
248
-
249
- // const variants = [] as SQL[];
250
-
251
- // for (const variant of filters.OR) {
252
- // const extracted = extractFilters(table, tableName, variant);
253
- // if (extracted) {
254
- // variants.push(extracted);
255
- // }
256
- // }
257
-
258
- // return variants.length ? (variants.length > 1 ? ops.or(...variants) : variants[0]) : undefined;
259
- // }
260
-
261
- // const variants = [] as SQL[];
262
- // for (const [columnName, operators] of entries) {
263
- // if (operators === null) {
264
- // continue;
265
- // }
266
-
267
- // const column = table.columns[columnName]!;
268
- // variants.push(
269
- // extractFiltersColumn(column as Column, columnName, operators as Record<string, unknown>)!,
270
- // );
271
- // }
272
-
273
- // return variants.length ? (variants.length > 1 ? ops.and(...variants) : variants[0]) : undefined;
274
- // };
@@ -1,49 +0,0 @@
1
- import { createContextCache } from '@pothos/core';
2
- import type { GraphQLResolveInfo } from 'graphql';
3
-
4
- export type LoaderMappings = Record<
5
- string,
6
- {
7
- field: string;
8
- type: string;
9
- mappings: LoaderMappings;
10
- indirectPath: string[];
11
- }
12
- >;
13
-
14
- const cache = createContextCache(() => new Map<string, LoaderMappings>());
15
-
16
- export function cacheKey(type: string, path: GraphQLResolveInfo['path'], subPath: string[] = []) {
17
- let key = '';
18
- let current: GraphQLResolveInfo['path'] | undefined = path;
19
-
20
- while (current) {
21
- if (typeof current.key === 'string') {
22
- key = key ? `${current.key}.${key}` : current.key;
23
- }
24
- current = current.prev;
25
- }
26
-
27
- for (const entry of subPath) {
28
- key = `${key}.${entry}`;
29
- }
30
-
31
- return `${type}@${key}`;
32
- }
33
-
34
- export function setLoaderMappings(ctx: object, info: GraphQLResolveInfo, value: LoaderMappings) {
35
- const map = cache(ctx);
36
- for (const [field, mapping] of Object.entries(value)) {
37
- const subPath = [...mapping.indirectPath, field];
38
- const key = cacheKey(mapping.type, info.path, subPath);
39
-
40
- map.set(key, mapping.mappings);
41
- }
42
- }
43
-
44
- export function getLoaderMapping(ctx: object, path: GraphQLResolveInfo['path'], type: string) {
45
- const map = cache(ctx);
46
- const key = cacheKey(type, path, []);
47
-
48
- return map.get(key) ?? null;
49
- }
@@ -1,62 +0,0 @@
1
- export const usageSymbol = Symbol.for('Pothos.isUsed');
2
-
3
- export function wrapWithUsageCheck<T extends object>(obj: T): T {
4
- const result = {};
5
- let used = true;
6
-
7
- Object.defineProperty(result, usageSymbol, {
8
- get() {
9
- return used;
10
- },
11
- set(value: boolean) {
12
- used = value;
13
- },
14
- enumerable: false,
15
- });
16
-
17
- for (const key of Object.keys(obj)) {
18
- // only set to false if the object has keys
19
- used = false;
20
- Object.defineProperty(result, key, {
21
- enumerable: true,
22
- configurable: true,
23
- get() {
24
- used = true;
25
- return obj[key as keyof T];
26
- },
27
- });
28
- }
29
-
30
- return result as T;
31
- }
32
-
33
- export function isUsed(obj: object): boolean {
34
- return !(usageSymbol in obj) || (obj as { [usageSymbol]: boolean })[usageSymbol];
35
- }
36
-
37
- export function extendWithUsage<T extends object, U extends object>(
38
- original: T,
39
- extension: U,
40
- ): T & U {
41
- if (!(usageSymbol in original)) {
42
- return { ...original, ...extension };
43
- }
44
-
45
- const result = { ...extension };
46
-
47
- for (const key of [usageSymbol, ...Object.keys(original)]) {
48
- if (key in result) {
49
- continue;
50
- }
51
-
52
- Object.defineProperty(result, key, {
53
- enumerable: key !== usageSymbol,
54
- configurable: key !== usageSymbol,
55
- get() {
56
- return original[key as keyof T];
57
- },
58
- });
59
- }
60
-
61
- return result as T & U;
62
- }