@pothos/plugin-prisma 4.0.5 → 4.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.
Files changed (171) hide show
  1. package/CHANGELOG.md +17 -4
  2. package/dts/connection-helpers.d.ts +2 -2
  3. package/dts/connection-helpers.d.ts.map +1 -1
  4. package/dts/global-types.d.ts +9 -9
  5. package/dts/global-types.d.ts.map +1 -1
  6. package/dts/index.d.ts +2 -2
  7. package/dts/index.d.ts.map +1 -1
  8. package/dts/interface-ref.d.ts +2 -2
  9. package/dts/interface-ref.d.ts.map +1 -1
  10. package/dts/model-loader.d.ts +4 -4
  11. package/dts/model-loader.d.ts.map +1 -1
  12. package/dts/node-ref.d.ts +1 -1
  13. package/dts/node-ref.d.ts.map +1 -1
  14. package/dts/object-ref.d.ts +1 -1
  15. package/dts/object-ref.d.ts.map +1 -1
  16. package/dts/prisma-field-builder.d.ts +5 -5
  17. package/dts/prisma-field-builder.d.ts.map +1 -1
  18. package/dts/types.d.ts +8 -8
  19. package/dts/types.d.ts.map +1 -1
  20. package/dts/util/cursors.d.ts +3 -3
  21. package/dts/util/cursors.d.ts.map +1 -1
  22. package/dts/util/datamodel.d.ts +3 -3
  23. package/dts/util/datamodel.d.ts.map +1 -1
  24. package/dts/util/deep-equal.d.ts.map +1 -1
  25. package/dts/util/description.d.ts +1 -1
  26. package/dts/util/description.d.ts.map +1 -1
  27. package/dts/util/get-client.d.ts +2 -2
  28. package/dts/util/get-client.d.ts.map +1 -1
  29. package/dts/util/loader-map.d.ts +2 -2
  30. package/dts/util/loader-map.d.ts.map +1 -1
  31. package/dts/util/map-query.d.ts +13 -8
  32. package/dts/util/map-query.d.ts.map +1 -1
  33. package/dts/util/relation-map.d.ts +1 -1
  34. package/dts/util/relation-map.d.ts.map +1 -1
  35. package/dts/util/selections.d.ts +2 -2
  36. package/dts/util/selections.d.ts.map +1 -1
  37. package/dts/util/usage.d.ts.map +1 -1
  38. package/esm/connection-helpers.d.ts +2 -2
  39. package/esm/connection-helpers.d.ts.map +1 -1
  40. package/esm/field-builder.js +6 -6
  41. package/esm/field-builder.js.map +1 -1
  42. package/esm/generator.js +5 -5
  43. package/esm/generator.js.map +1 -1
  44. package/esm/global-types.d.ts +9 -9
  45. package/esm/global-types.d.ts.map +1 -1
  46. package/esm/global-types.js +1 -1
  47. package/esm/global-types.js.map +1 -1
  48. package/esm/index.d.ts +2 -2
  49. package/esm/index.d.ts.map +1 -1
  50. package/esm/index.js +4 -4
  51. package/esm/index.js.map +1 -1
  52. package/esm/interface-ref.d.ts +2 -2
  53. package/esm/interface-ref.d.ts.map +1 -1
  54. package/esm/interface-ref.js.map +1 -1
  55. package/esm/model-loader.d.ts +4 -4
  56. package/esm/model-loader.d.ts.map +1 -1
  57. package/esm/model-loader.js +13 -15
  58. package/esm/model-loader.js.map +1 -1
  59. package/esm/node-ref.d.ts +1 -1
  60. package/esm/node-ref.d.ts.map +1 -1
  61. package/esm/object-ref.d.ts +1 -1
  62. package/esm/object-ref.d.ts.map +1 -1
  63. package/esm/object-ref.js +4 -2
  64. package/esm/object-ref.js.map +1 -1
  65. package/esm/prisma-field-builder.d.ts +5 -5
  66. package/esm/prisma-field-builder.d.ts.map +1 -1
  67. package/esm/prisma-field-builder.js +7 -8
  68. package/esm/prisma-field-builder.js.map +1 -1
  69. package/esm/schema-builder.js +1 -1
  70. package/esm/schema-builder.js.map +1 -1
  71. package/esm/types.d.ts +8 -8
  72. package/esm/types.d.ts.map +1 -1
  73. package/esm/types.js.map +1 -1
  74. package/esm/util/cursors.d.ts +3 -3
  75. package/esm/util/cursors.d.ts.map +1 -1
  76. package/esm/util/cursors.js +2 -2
  77. package/esm/util/cursors.js.map +1 -1
  78. package/esm/util/datamodel.d.ts +3 -3
  79. package/esm/util/datamodel.d.ts.map +1 -1
  80. package/esm/util/datamodel.js.map +1 -1
  81. package/esm/util/deep-equal.d.ts.map +1 -1
  82. package/esm/util/deep-equal.js +1 -1
  83. package/esm/util/deep-equal.js.map +1 -1
  84. package/esm/util/description.d.ts +1 -1
  85. package/esm/util/description.d.ts.map +1 -1
  86. package/esm/util/description.js +1 -1
  87. package/esm/util/description.js.map +1 -1
  88. package/esm/util/get-client.d.ts +2 -2
  89. package/esm/util/get-client.d.ts.map +1 -1
  90. package/esm/util/get-client.js +1 -1
  91. package/esm/util/get-client.js.map +1 -1
  92. package/esm/util/loader-map.d.ts +2 -2
  93. package/esm/util/loader-map.d.ts.map +1 -1
  94. package/esm/util/loader-map.js +4 -5
  95. package/esm/util/loader-map.js.map +1 -1
  96. package/esm/util/map-query.d.ts +13 -8
  97. package/esm/util/map-query.d.ts.map +1 -1
  98. package/esm/util/map-query.js +20 -19
  99. package/esm/util/map-query.js.map +1 -1
  100. package/esm/util/relation-map.d.ts +1 -1
  101. package/esm/util/relation-map.d.ts.map +1 -1
  102. package/esm/util/relation-map.js +12 -12
  103. package/esm/util/relation-map.js.map +1 -1
  104. package/esm/util/selections.d.ts +2 -2
  105. package/esm/util/selections.d.ts.map +1 -1
  106. package/esm/util/selections.js +9 -9
  107. package/esm/util/selections.js.map +1 -1
  108. package/esm/util/usage.d.ts.map +1 -1
  109. package/esm/util/usage.js +0 -1
  110. package/esm/util/usage.js.map +1 -1
  111. package/generated.d.ts +1 -1
  112. package/lib/field-builder.js +7 -5
  113. package/lib/field-builder.js.map +1 -1
  114. package/lib/generator.js +4 -4
  115. package/lib/generator.js.map +1 -1
  116. package/lib/global-types.js +1 -1
  117. package/lib/global-types.js.map +1 -1
  118. package/lib/index.js +4 -4
  119. package/lib/index.js.map +1 -1
  120. package/lib/interface-ref.js.map +1 -1
  121. package/lib/model-loader.js +12 -14
  122. package/lib/model-loader.js.map +1 -1
  123. package/lib/object-ref.js +3 -1
  124. package/lib/object-ref.js.map +1 -1
  125. package/lib/prisma-field-builder.js +6 -7
  126. package/lib/prisma-field-builder.js.map +1 -1
  127. package/lib/schema-builder.js +1 -1
  128. package/lib/schema-builder.js.map +1 -1
  129. package/lib/types.js.map +1 -1
  130. package/lib/util/cursors.js +2 -2
  131. package/lib/util/cursors.js.map +1 -1
  132. package/lib/util/datamodel.js.map +1 -1
  133. package/lib/util/deep-equal.js +1 -1
  134. package/lib/util/deep-equal.js.map +1 -1
  135. package/lib/util/description.js +1 -1
  136. package/lib/util/description.js.map +1 -1
  137. package/lib/util/get-client.js +1 -1
  138. package/lib/util/get-client.js.map +1 -1
  139. package/lib/util/loader-map.js +4 -5
  140. package/lib/util/loader-map.js.map +1 -1
  141. package/lib/util/map-query.js +20 -19
  142. package/lib/util/map-query.js.map +1 -1
  143. package/lib/util/relation-map.js +12 -12
  144. package/lib/util/relation-map.js.map +1 -1
  145. package/lib/util/selections.js +9 -9
  146. package/lib/util/selections.js.map +1 -1
  147. package/lib/util/usage.js +0 -1
  148. package/lib/util/usage.js.map +1 -1
  149. package/package.json +12 -12
  150. package/src/connection-helpers.ts +2 -2
  151. package/src/field-builder.ts +30 -19
  152. package/src/generator.ts +5 -8
  153. package/src/global-types.ts +33 -28
  154. package/src/index.ts +12 -11
  155. package/src/interface-ref.ts +2 -2
  156. package/src/model-loader.ts +17 -19
  157. package/src/node-ref.ts +1 -1
  158. package/src/object-ref.ts +5 -3
  159. package/src/prisma-field-builder.ts +54 -53
  160. package/src/schema-builder.ts +8 -8
  161. package/src/types.ts +59 -60
  162. package/src/util/cursors.ts +7 -8
  163. package/src/util/datamodel.ts +3 -3
  164. package/src/util/deep-equal.ts +0 -1
  165. package/src/util/description.ts +1 -2
  166. package/src/util/get-client.ts +2 -3
  167. package/src/util/loader-map.ts +6 -8
  168. package/src/util/map-query.ts +49 -46
  169. package/src/util/relation-map.ts +13 -13
  170. package/src/util/selections.ts +10 -12
  171. package/src/util/usage.ts +0 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/util/selections.ts"],"names":["createState","mergeSelection","mergeState","selectionCompatible","selectionToQuery","stateCompatible","state","selectionMap","ignoreQuery","Object","keys","query","length","select","include","some","key","compare","deepEqual","value","selections","k","counts","has","get","fieldMap","relations","newState","name","relationState","mode","fields","add","parent","Set","Map","mappings","forEach","merge","count","set","selection","childMap","relatedState","nestedIncludes","hasSelection","sel","relation","nested","size","_count","field"],"mappings":"AAAA,oCAAoC,GACpC,uCAAuC;;;;;;;;;;;IA4FvBA,WAAW;eAAXA;;IAiBAC,cAAc;eAAdA;;IAjCAC,UAAU;eAAVA;;IA1DAC,mBAAmB;eAAnBA;;IA+IAC,gBAAgB;eAAhBA;;IAnGAC,eAAe;eAAfA;;;2BA5DU;AAgBnB,SAASF,oBACdG,KAAqB,EACrBC,YAAoC,EACpCC,cAAc,KAAK;IAEnB,IAAI,OAAOD,iBAAiB,WAAW;QACrC,OAAOC,eAAe,CAACD,gBAAgBE,OAAOC,IAAI,CAACJ,MAAMK,KAAK,EAAEC,MAAM,KAAK;IAC7E;IAEA,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGH,OAAO,GAAGJ;IAEtC,IAAIM,UAAUJ,OAAOC,IAAI,CAACG,QAAQE,IAAI,CAAC,CAACC,MAAQC,QAAQD,KAAKH,MAAM,CAACG,IAAI,IAAI;QAC1E,OAAO;IACT;IAEA,IAAIF,WAAWL,OAAOC,IAAI,CAACI,SAASC,IAAI,CAAC,CAACC,MAAQC,QAAQD,KAAKF,OAAO,CAACE,IAAI,IAAI;QAC7E,OAAO;IACT;IAEA,OAAOR,eAAeU,IAAAA,oBAAS,EAACZ,MAAMK,KAAK,EAAEA;IAE7C,SAASM,QAAQD,GAAW,EAAEG,KAA6B;QACzD,IAAIH,QAAQ,UAAU;YACpB,MAAMI,aAAaD,SAAS,AAACA,MAA+CN,MAAM;YAClF,MAAMH,OAAOU,cAAcX,OAAOC,IAAI,CAACU;YAEvC,IAAI,CAACV,QAAQA,KAAKE,MAAM,KAAK,GAAG;gBAC9B,OAAO;YACT;YAEA,OAAOF,KAAKK,IAAI,CACd,CAACM,IAAMf,MAAMgB,MAAM,CAACC,GAAG,CAACF,MAAM,CAACH,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AC3B;QACF,OAAO;YACLrC,MAAMyB,MAAM,CAACC,GAAG,CAAChB;QACnB;IACF;AACF;AAEO,SAASZ,iBAAiBE,KAAqB;IACpD,MAAMsC,iBAAyD,CAAC;IAChE,MAAMtB,SAAkC,CAAC;IAEzC,IAAIuB,eAAe;IAEnBvC,MAAMoB,SAAS,CAACW,OAAO,CAAC,CAACS,KAAKC;QAC5BF,eAAe;QACf,MAAMG,SAAS5C,iBAAiB0C;QAChCF,cAAc,CAACG,SAAS,GAAGtC,OAAOC,IAAI,CAACsC,QAAQpC,MAAM,GAAG,IAAIoC,SAAS;IACvE;IAEA,IAAI1C,MAAMgB,MAAM,CAAC2B,IAAI,GAAG,GAAG;QACzBJ,eAAe;QACf,KAAK,MAAM,CAACN,OAAOE,UAAU,IAAInC,MAAMgB,MAAM,CAAE;YAC7CA,MAAM,CAACiB,MAAM,GAAGE;QAClB;QAEAG,eAAeM,MAAM,GAAG;YACtBrC,QAAQS;QACV;IACF;IAEA,IAAIhB,MAAMwB,IAAI,KAAK,UAAU;QAC3BxB,MAAMyB,MAAM,CAACM,OAAO,CAAC,CAACc;YACpBN,eAAe;YACfD,cAAc,CAACO,MAAM,GAAG;QAC1B;QAEA,OAAO;YACL,GAAI7C,MAAMK,KAAK;YACfE,QAAQ+B;QACV;IACF;IAEA,OAAOC,eACH;QACE,GAAGvC,MAAMK,KAAK;QACdG,SAAS8B;IACX,IACCtC,MAAMK,KAAK;AAClB"}
1
+ {"version":3,"sources":["../../src/util/selections.ts"],"names":["createState","mergeSelection","mergeState","selectionCompatible","selectionToQuery","stateCompatible","state","selectionMap","ignoreQuery","Object","keys","query","length","select","include","some","key","compare","deepEqual","value","selections","k","counts","has","get","fieldMap","relations","newState","name","relationState","mode","fields","add","parent","Set","Map","mappings","merge","count","set","selection","childMap","relatedState","nestedIncludes","hasSelection","forEach","sel","relation","nested","size","_count","field"],"mappings":";;;;;;;;;;;IA2FgBA,WAAW;eAAXA;;IAiBAC,cAAc;eAAdA;;I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KC;QAC5BH,eAAe;QACf,MAAMI,SAAS5C,iBAAiB0C;QAChCH,cAAc,CAACI,SAAS,GAAGtC,OAAOC,IAAI,CAACsC,QAAQpC,MAAM,GAAG,IAAIoC,SAAS;IACvE;IAEA,IAAI1C,MAAMgB,MAAM,CAAC2B,IAAI,GAAG,GAAG;QACzBL,eAAe;QACf,KAAK,MAAM,CAACN,OAAOE,UAAU,IAAIlC,MAAMgB,MAAM,CAAE;YAC7CA,MAAM,CAACgB,MAAM,GAAGE;QAClB;QAEAG,eAAeO,MAAM,GAAG;YACtBrC,QAAQS;QACV;IACF;IAEA,IAAIhB,MAAMwB,IAAI,KAAK,UAAU;QAC3B,KAAK,MAAMqB,SAAS7C,MAAMyB,MAAM,CAAE;YAChCa,eAAe;YACfD,cAAc,CAACQ,MAAM,GAAG;QAC1B;QAEA,OAAO;YACL,GAAI7C,MAAMK,KAAK;YACfE,QAAQ8B;QACV;IACF;IAEA,OAAOC,eACH;QACE,GAAGtC,MAAMK,KAAK;QACdG,SAAS6B;IACX,IACCrC,MAAMK,KAAK;AAClB"}
package/lib/util/usage.js CHANGED
@@ -41,7 +41,6 @@ function wrapWithUsageCheck(obj) {
41
41
  Object.defineProperty(result, key, {
42
42
  enumerable: true,
43
43
  configurable: true,
44
- // eslint-disable-next-line @typescript-eslint/no-loop-func
45
44
  get () {
46
45
  used = true;
47
46
  return obj[key];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/util/usage.ts"],"names":["extendWithUsage","isUsed","usageSymbol","wrapWithUsageCheck","Symbol","for","obj","result","used","Object","defineProperty","get","set","value","enumerable","key","keys","configurable","original","extension"],"mappings":";;;;;;;;;;;IAqCgBA,eAAe;eAAfA;;IAJAC,MAAM;eAANA;;IAjCHC,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;YACd,2DAA2D;YAC3DN;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;YAEjB;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
+ {"version":3,"sources":["../../src/util/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-prisma",
3
- "version": "4.0.5",
3
+ "version": "4.2.0",
4
4
  "description": "A Pothos plugin for more efficient integration with prisma",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./dts/index.d.ts",
@@ -54,30 +54,30 @@
54
54
  "provenance": true
55
55
  },
56
56
  "dependencies": {
57
- "@prisma/generator-helper": "^5.16.2"
57
+ "@prisma/generator-helper": "^5.17.0"
58
58
  },
59
59
  "prisma": {
60
60
  "seed": "node prisma/seed.mjs"
61
61
  },
62
62
  "peerDependencies": {
63
- "@pothos/core": "4.0.2",
63
+ "@pothos/core": "*",
64
64
  "@prisma/client": "*",
65
65
  "graphql": ">=16.6.0",
66
66
  "typescript": ">=4.7.2"
67
67
  },
68
68
  "devDependencies": {
69
- "@prisma/client": "^5.16.2",
69
+ "@prisma/client": "^5.17.0",
70
70
  "graphql": "^16.8.1",
71
71
  "graphql-scalars": "^1.23.0",
72
72
  "graphql-tag": "^2.12.6",
73
- "prisma": "^5.16.2",
74
- "vitest": "^2.0.1",
75
- "@pothos/core": "4.0.2",
76
- "@pothos/plugin-complexity": "4.0.2",
77
- "@pothos/plugin-errors": "4.0.2",
78
- "@pothos/plugin-relay": "4.0.2",
79
- "@pothos/plugin-simple-objects": "4.0.3",
80
- "@pothos/test-utils": "2.0.1"
73
+ "prisma": "^5.17.0",
74
+ "vitest": "^2.0.5",
75
+ "@pothos/core": "4.1.0",
76
+ "@pothos/plugin-complexity": "4.1.0",
77
+ "@pothos/plugin-errors": "4.2.0",
78
+ "@pothos/plugin-relay": "4.1.0",
79
+ "@pothos/plugin-simple-objects": "4.1.0",
80
+ "@pothos/test-utils": "2.1.0"
81
81
  },
82
82
  "scripts": {
83
83
  "generate": "prisma generate && prisma generate --schema=./tests/prisma-types-from-client/schema.prisma",
@@ -1,5 +1,5 @@
1
- import { InputFieldMap, InputShapeFromFields, ObjectRef, SchemaTypes } from '@pothos/core';
2
- import { PrismaRef } from './interface-ref';
1
+ import type { InputFieldMap, InputShapeFromFields, ObjectRef, SchemaTypes } from '@pothos/core';
2
+ import type { PrismaRef } from './interface-ref';
3
3
  import { ModelLoader } from './model-loader';
4
4
  import type { PrismaModelTypes, ShapeFromSelection, UniqueFieldsFromWhereUnique } from './types';
5
5
  import {
@@ -1,17 +1,23 @@
1
- import { getNamedType, GraphQLResolveInfo, isInterfaceType, isObjectType, Kind } from 'graphql';
2
1
  import {
3
- FieldKind,
4
- FieldRef,
5
- InputFieldMap,
6
- isThenable,
7
- MaybePromise,
2
+ type FieldKind,
3
+ type FieldRef,
4
+ type InputFieldMap,
5
+ type MaybePromise,
8
6
  ObjectRef,
9
7
  PothosError,
10
8
  RootFieldBuilder,
11
- SchemaTypes,
9
+ type SchemaTypes,
10
+ isThenable,
12
11
  } from '@pothos/core';
12
+ import {
13
+ type GraphQLResolveInfo,
14
+ Kind,
15
+ getNamedType,
16
+ isInterfaceType,
17
+ isObjectType,
18
+ } from 'graphql';
13
19
  import { ModelLoader } from './model-loader';
14
- import { PrismaConnectionFieldOptions, PrismaModelTypes } from './types';
20
+ import type { PrismaConnectionFieldOptions, PrismaModelTypes } from './types';
15
21
  import { getCursorFormatter, getCursorParser, resolvePrismaCursorConnection } from './util/cursors';
16
22
  import { getRefFromModel } from './util/datamodel';
17
23
  import { queryFromInfo } from './util/map-query';
@@ -52,11 +58,14 @@ fieldBuilderProto.prismaField = function prismaField({ type, resolve, ...options
52
58
  }) as never;
53
59
  };
54
60
 
55
- fieldBuilderProto.prismaFieldWithInput = function prismaFieldWithInput({
56
- type,
57
- resolve,
58
- ...options
59
- }) {
61
+ fieldBuilderProto.prismaFieldWithInput = function prismaFieldWithInput(
62
+ this: typeof fieldBuilderProto,
63
+ {
64
+ type,
65
+ resolve,
66
+ ...options
67
+ }: { type: ObjectRef<SchemaTypes, unknown> | [string]; resolve: (...args: unknown[]) => unknown },
68
+ ) {
60
69
  const modelOrRef = Array.isArray(type) ? type[0] : type;
61
70
  const typeRef =
62
71
  typeof modelOrRef === 'string'
@@ -85,7 +94,7 @@ fieldBuilderProto.prismaFieldWithInput = function prismaFieldWithInput({
85
94
  );
86
95
  },
87
96
  }) as never;
88
- };
97
+ } as never;
89
98
 
90
99
  fieldBuilderProto.prismaConnection = function prismaConnection<
91
100
  Type extends keyof SchemaTypes['PrismaTypes'],
@@ -174,7 +183,9 @@ fieldBuilderProto.prismaConnection = function prismaConnection<
174
183
  },
175
184
  formatCursor,
176
185
  (q) => {
177
- if (totalCountOnly) return [];
186
+ if (totalCountOnly) {
187
+ return [];
188
+ }
178
189
 
179
190
  return checkIfQueryIsUsed(
180
191
  this.builder,
@@ -202,13 +213,13 @@ fieldBuilderProto.prismaConnection = function prismaConnection<
202
213
  extensions: {
203
214
  pothosPrismaTotalCount: true,
204
215
  },
205
- resolve: (parent, args, context) => parent.totalCount?.(),
216
+ resolve: (parent) => parent.totalCount?.(),
206
217
  }),
207
218
  ...(connectionOptions as { fields?: (t: unknown) => {} }).fields?.(t),
208
219
  })
209
220
  : (connectionOptions as { fields: undefined }).fields,
210
221
  extensions: {
211
- ...(connectionOptions as Record<string, {}> | undefined)?.extensions,
222
+ ...(connectionOptions as Record<string, object> | undefined)?.extensions,
212
223
  },
213
224
  },
214
225
  edgeOptions,
@@ -254,8 +265,8 @@ function checkIfQueryIsUsed<Types extends SchemaTypes, T>(
254
265
 
255
266
  if (onUnusedQuery === 'error') {
256
267
  throw new PothosError(message);
257
- } else if (onUnusedQuery === 'warn') {
258
- // eslint-disable-next-line no-console
268
+ }
269
+ if (onUnusedQuery === 'warn') {
259
270
  console.warn(message);
260
271
  }
261
272
  }
package/src/generator.ts CHANGED
@@ -1,11 +1,8 @@
1
- /* eslint-disable unicorn/prefer-module */
2
- /* eslint-disable no-magic-numbers */
3
- /* eslint-disable no-nested-ternary */
4
1
  import { mkdirSync, writeFileSync } from 'node:fs';
5
- import { dirname, join, resolve as resolvePath, posix } from 'node:path';
2
+ import { dirname, join, posix, resolve as resolvePath } from 'node:path';
3
+ import { type DMMF, generatorHandler } from '@prisma/generator-helper';
6
4
  import ts, { ListFormat, ScriptKind, ScriptTarget, SyntaxKind, version } from 'typescript';
7
- import { DMMF, generatorHandler } from '@prisma/generator-helper';
8
- import { PothosPrismaDatamodel } from './types';
5
+ import type { PothosPrismaDatamodel } from './types';
9
6
 
10
7
  const MIN_TS_VERSION = [4, 5, 2];
11
8
 
@@ -83,7 +80,7 @@ function trimDmmf(dmmf: DMMF.Document, documentation = false): PothosPrismaDatam
83
80
  },
84
81
  };
85
82
 
86
- dmmf.datamodel.models.forEach((model) => {
83
+ for (const model of dmmf.datamodel.models) {
87
84
  trimmed.datamodel.models[model.name] = {
88
85
  fields: model.fields.map((field) => ({
89
86
  type: field.type,
@@ -108,7 +105,7 @@ function trimDmmf(dmmf: DMMF.Document, documentation = false): PothosPrismaDatam
108
105
  })),
109
106
  documentation: documentation ? model.documentation : undefined,
110
107
  };
111
- });
108
+ }
112
109
 
113
110
  return trimmed;
114
111
  }
@@ -1,7 +1,4 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
- /* eslint-disable @typescript-eslint/no-empty-interface */
3
- import { GraphQLResolveInfo } from 'graphql';
4
- import {
1
+ import type {
5
2
  FieldKind,
6
3
  FieldMap,
7
4
  FieldNullability,
@@ -15,24 +12,25 @@ import {
15
12
  ShapeFromTypeParam,
16
13
  TypeParam,
17
14
  } from '@pothos/core';
18
- import { PrismaInterfaceRef, PrismaRef } from './interface-ref';
19
- import { PrismaNodeRef } from './node-ref';
20
- import { prismaModelKey, PrismaObjectRef } from './object-ref';
21
- import { PrismaObjectFieldBuilder as InternalPrismaObjectFieldBuilder } from './prisma-field-builder';
15
+ import type { GraphQLResolveInfo } from 'graphql';
16
+ import type { PrismaInterfaceRef, PrismaRef } from './interface-ref';
17
+ import type { PrismaNodeRef } from './node-ref';
18
+ import type { PrismaObjectRef, prismaModelKey } from './object-ref';
19
+ import type { PrismaObjectFieldBuilder as InternalPrismaObjectFieldBuilder } from './prisma-field-builder';
22
20
  import {
23
- PrismaClient,
24
- PrismaConnectionFieldOptions,
25
- PrismaConnectionShape,
26
- PrismaFieldOptions,
27
- PrismaFieldWithInputOptions,
28
- PrismaInterfaceTypeOptions,
21
+ type PrismaClient,
22
+ type PrismaConnectionFieldOptions,
23
+ type PrismaConnectionShape,
24
+ type PrismaFieldOptions,
25
+ type PrismaFieldWithInputOptions,
26
+ type PrismaInterfaceTypeOptions,
27
+ type PrismaModelTypes,
28
+ type PrismaNodeOptions,
29
+ type PrismaObjectFieldOptions,
30
+ type PrismaObjectTypeOptions,
31
+ type ShapeFromConnection,
32
+ type ShapeFromSelection,
29
33
  prismaModelName,
30
- PrismaModelTypes,
31
- PrismaNodeOptions,
32
- PrismaObjectFieldOptions,
33
- PrismaObjectTypeOptions,
34
- ShapeFromConnection,
35
- ShapeFromSelection,
36
34
  } from './types';
37
35
 
38
36
  import type { PothosPrismaPlugin } from '.';
@@ -254,10 +252,11 @@ declare global {
254
252
  > {
255
253
  prismaField: <
256
254
  Args extends InputFieldMap,
257
- TypeParam extends
255
+ TypeParam extends // biome-ignore lint/suspicious/noExplicitAny: <explanation>
258
256
  | PrismaRef<any, PrismaModelTypes>
259
257
  | keyof Types['PrismaTypes']
260
258
  | [keyof Types['PrismaTypes']]
259
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
261
260
  | [PrismaRef<any, PrismaModelTypes>],
262
261
  Nullable extends FieldNullability<Type>,
263
262
  ResolveShape,
@@ -268,9 +267,11 @@ declare global {
268
267
  Model extends PrismaModelTypes = PrismaModelTypes &
269
268
  (TypeParam extends [keyof Types['PrismaTypes']]
270
269
  ? Types['PrismaTypes'][TypeParam[0]]
271
- : TypeParam extends [PrismaRef<any, PrismaModelTypes>]
270
+ : // biome-ignore lint/suspicious/noExplicitAny: <explanation>
271
+ TypeParam extends [PrismaRef<any, PrismaModelTypes>]
272
272
  ? TypeParam[0][typeof prismaModelKey]
273
- : TypeParam extends PrismaRef<any, PrismaModelTypes>
273
+ : // biome-ignore lint/suspicious/noExplicitAny: <explanation>
274
+ TypeParam extends PrismaRef<any, PrismaModelTypes>
274
275
  ? TypeParam[typeof prismaModelKey]
275
276
  : TypeParam extends keyof Types['PrismaTypes']
276
277
  ? Types['PrismaTypes'][TypeParam]
@@ -292,6 +293,7 @@ declare global {
292
293
 
293
294
  prismaConnection: 'relay' extends PluginName
294
295
  ? <
296
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
295
297
  Type extends PrismaRef<any, PrismaModelTypes> | keyof Types['PrismaTypes'],
296
298
  Nullable extends boolean,
297
299
  ResolveReturnShape,
@@ -353,13 +355,14 @@ declare global {
353
355
  >
354
356
  : '@pothos/plugin-relay is required to use this method';
355
357
 
356
- prismaFieldWithInput: 'prisma' extends PluginName
358
+ prismaFieldWithInput: 'withInput' extends PluginName
357
359
  ? <
358
360
  Fields extends InputFieldMap,
359
- TypeParam extends
361
+ TypeParam extends // biome-ignore lint/suspicious/noExplicitAny: <explanation>
360
362
  | PrismaRef<any, PrismaModelTypes>
361
363
  | keyof Types['PrismaTypes']
362
364
  | [keyof Types['PrismaTypes']]
365
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
363
366
  | [PrismaRef<any, PrismaModelTypes>],
364
367
  Type extends TypeParam extends [unknown]
365
368
  ? [ObjectRef<Types, Model['Shape']>]
@@ -373,9 +376,11 @@ declare global {
373
376
  Model extends PrismaModelTypes = PrismaModelTypes &
374
377
  (TypeParam extends [keyof Types['PrismaTypes']]
375
378
  ? Types['PrismaTypes'][TypeParam[0]]
376
- : TypeParam extends [PrismaRef<any, PrismaModelTypes>]
379
+ : // biome-ignore lint/suspicious/noExplicitAny: <explanation>
380
+ TypeParam extends [PrismaRef<any, PrismaModelTypes>]
377
381
  ? TypeParam[0][typeof prismaModelKey]
378
- : TypeParam extends PrismaRef<any, PrismaModelTypes>
382
+ : // biome-ignore lint/suspicious/noExplicitAny: <explanation>
383
+ TypeParam extends PrismaRef<any, PrismaModelTypes>
379
384
  ? TypeParam[typeof prismaModelKey]
380
385
  : TypeParam extends keyof Types['PrismaTypes']
381
386
  ? Types['PrismaTypes'][TypeParam]
@@ -399,7 +404,7 @@ declare global {
399
404
  : ArgRequired
400
405
  >,
401
406
  ) => FieldRef<Types, ShapeFromTypeParam<Types, Type, Nullable>>
402
- : '@pothos/plugin-prisma is required to use this method';
407
+ : '@pothos/plugin-with-input is required to use this method';
403
408
  }
404
409
 
405
410
  export interface ConnectionFieldOptions<
package/src/index.ts CHANGED
@@ -1,18 +1,19 @@
1
1
  import './global-types';
2
2
  import './schema-builder';
3
3
  import './field-builder';
4
- import { GraphQLFieldResolver, GraphQLResolveInfo } from 'graphql';
5
4
  import SchemaBuilder, {
6
5
  BasePlugin,
7
- BuildCache,
8
- PothosOutputFieldConfig,
6
+ type BuildCache,
7
+ type PothosOutputFieldConfig,
9
8
  PothosSchemaError,
10
- PothosTypeConfig,
11
- SchemaTypes,
9
+ type PothosTypeConfig,
10
+ type SchemaTypes,
12
11
  } from '@pothos/core';
13
- import { ModelLoader } from './model-loader';
12
+ // biome-ignore lint/style/useImportType: <explanation>
13
+ import { GraphQLFieldResolver, GraphQLResolveInfo } from 'graphql';
14
+ import type { ModelLoader } from './model-loader';
14
15
  import { PrismaObjectFieldBuilder as InternalPrismaObjectFieldBuilder } from './prisma-field-builder';
15
- import { PrismaModelTypes } from './types';
16
+ import type { PrismaModelTypes } from './types';
16
17
  import { formatPrismaCursor, parsePrismaCursor } from './util/cursors';
17
18
  import { getModel, getRefFromModel } from './util/datamodel';
18
19
  import { getLoaderMapping, setLoaderMappings } from './util/loader-map';
@@ -56,7 +57,7 @@ export class PothosPrismaPlugin<Types extends SchemaTypes> extends BasePlugin<Ty
56
57
 
57
58
  let model = typeConfig.extensions?.pothosPrismaModel as string | undefined;
58
59
 
59
- typeConfig.interfaces.forEach((iface) => {
60
+ for (const iface of typeConfig.interfaces) {
60
61
  const interfaceModel = this.buildCache.getTypeConfig(iface, 'Interface').extensions
61
62
  ?.pothosPrismaModel as string | undefined;
62
63
 
@@ -69,7 +70,7 @@ export class PothosPrismaPlugin<Types extends SchemaTypes> extends BasePlugin<Ty
69
70
 
70
71
  model = interfaceModel;
71
72
  }
72
- });
73
+ }
73
74
 
74
75
  return {
75
76
  ...typeConfig,
@@ -133,12 +134,12 @@ export class PothosPrismaPlugin<Types extends SchemaTypes> extends BasePlugin<Ty
133
134
  const parentTypes = new Set([fieldConfig.parentType]);
134
135
 
135
136
  if (parentConfig.kind === 'Interface' || parentConfig.kind === 'Object') {
136
- parentConfig.interfaces.forEach((iface) => {
137
+ for (const iface of parentConfig.interfaces) {
137
138
  const interfaceConfig = this.buildCache.getTypeConfig(iface, 'Interface');
138
139
  if (interfaceConfig.extensions?.pothosPrismaModel) {
139
140
  parentTypes.add(interfaceConfig.name);
140
141
  }
141
- });
142
+ }
142
143
  }
143
144
 
144
145
  return (parent, args, context, info) => {
@@ -1,5 +1,5 @@
1
- import { InterfaceRef, SchemaTypes } from '@pothos/core';
2
- import { prismaModelKey, PrismaObjectRef } from './object-ref';
1
+ import { InterfaceRef, type SchemaTypes } from '@pothos/core';
2
+ import { type PrismaObjectRef, prismaModelKey } from './object-ref';
3
3
  import type { PrismaModelTypes } from './types';
4
4
 
5
5
  export type PrismaRef<Types extends SchemaTypes, Model extends PrismaModelTypes, T = {}> =
@@ -1,20 +1,20 @@
1
- import { GraphQLResolveInfo } from 'graphql';
2
1
  import {
3
- createContextCache,
4
- InterfaceRef,
5
- ObjectRef,
2
+ type InterfaceRef,
3
+ type ObjectRef,
6
4
  PothosSchemaError,
7
- SchemaTypes,
5
+ type SchemaTypes,
6
+ createContextCache,
8
7
  } from '@pothos/core';
9
- import { PrismaDelegate, SelectionMap } from './types';
8
+ import type { GraphQLResolveInfo } from 'graphql';
9
+ import type { PrismaDelegate, SelectionMap } from './types';
10
10
  import { getDelegateFromModel, getModel } from './util/datamodel';
11
11
  import { getClient } from './util/get-client';
12
12
  import { cacheKey, setLoaderMappings } from './util/loader-map';
13
13
  import { selectionStateFromInfo } from './util/map-query';
14
14
  import {
15
+ type SelectionState,
15
16
  mergeSelection,
16
17
  selectionCompatible,
17
- SelectionState,
18
18
  selectionToQuery,
19
19
  } from './util/selections';
20
20
 
@@ -75,7 +75,7 @@ export class ModelLoader {
75
75
  ? () => {
76
76
  throw new PothosSchemaError(`Missing findUnique for ${ref.name}`);
77
77
  }
78
- : findUnique ?? this.getDefaultFindUnique(ref, modelName, builder),
78
+ : findUnique ?? ModelLoader.getDefaultFindUnique(ref, modelName, builder),
79
79
  ),
80
80
  );
81
81
  }
@@ -147,9 +147,9 @@ export class ModelLoader {
147
147
  modelName: string,
148
148
  builder: PothosSchemaTypes.SchemaBuilder<Types>,
149
149
  ): (model: Record<string, unknown>) => {} {
150
- const findBy = this.getDefaultFindBy(ref, modelName, builder);
150
+ const findBy = ModelLoader.getDefaultFindBy(ref, modelName, builder);
151
151
 
152
- return this.getFindUnique(findBy);
152
+ return ModelLoader.getFindUnique(findBy);
153
153
  }
154
154
 
155
155
  static getDefaultIDSelection<Types extends SchemaTypes>(
@@ -157,7 +157,7 @@ export class ModelLoader {
157
157
  modelName: string,
158
158
  builder: PothosSchemaTypes.SchemaBuilder<Types>,
159
159
  ): Record<string, boolean> {
160
- const findBy = this.getDefaultFindBy(ref, modelName, builder);
160
+ const findBy = ModelLoader.getDefaultFindBy(ref, modelName, builder);
161
161
 
162
162
  if (typeof findBy === 'string') {
163
163
  return { [findBy]: true };
@@ -236,7 +236,7 @@ export class ModelLoader {
236
236
  throw new PothosSchemaError(`Unable to find field or index for ${fieldName} of ${ref.name}`);
237
237
  }
238
238
 
239
- return this.getFindUnique(findBy);
239
+ return ModelLoader.getFindUnique(findBy);
240
240
  }
241
241
 
242
242
  getSelection(info: GraphQLResolveInfo) {
@@ -277,7 +277,7 @@ export class ModelLoader {
277
277
  entry.models.set(model, createResolvablePromise<Record<string, unknown> | null>());
278
278
  }
279
279
 
280
- return entry.models.get(model)!.promise;
280
+ return await entry.models.get(model)!.promise;
281
281
  }
282
282
  }
283
283
 
@@ -298,31 +298,29 @@ export class ModelLoader {
298
298
  this.staged.add(entry);
299
299
 
300
300
  const nextTick = createResolvablePromise<void>();
301
- void this.tick.then(() => {
301
+ this.tick.then(() => {
302
302
  this.staged.delete(entry);
303
303
 
304
304
  for (const [model, { resolve, reject }] of entry.models) {
305
305
  if (this.delegate.findUniqueOrThrow) {
306
- void this.delegate
306
+ this.delegate
307
307
  .findUniqueOrThrow({
308
308
  ...selectionToQuery(state),
309
309
  where: { ...(this.findUnique(model as Record<string, unknown>, this.context) as {}) },
310
310
  } as never)
311
- // eslint-disable-next-line promise/no-nesting
312
311
  .then(resolve as () => {}, reject);
313
312
  } else {
314
- void this.delegate
313
+ this.delegate
315
314
  .findUnique({
316
315
  rejectOnNotFound: true,
317
316
  ...selectionToQuery(state),
318
317
  where: { ...(this.findUnique(model as Record<string, unknown>, this.context) as {}) },
319
318
  } as never)
320
- // eslint-disable-next-line promise/no-nesting
321
319
  .then(resolve as () => {}, reject);
322
320
  }
323
321
  }
324
322
  });
325
- setTimeout(() => void nextTick.resolve(), 0);
323
+ setTimeout(() => nextTick.resolve(), 0);
326
324
  this.tick = nextTick.promise;
327
325
 
328
326
  return promise.promise;
package/src/node-ref.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SchemaTypes } from '@pothos/core';
1
+ import type { SchemaTypes } from '@pothos/core';
2
2
  import { PrismaObjectRef } from './object-ref';
3
3
  import type { PrismaModelTypes } from './types';
4
4
 
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 { PrismaModelTypes, WithBrand } from './types';
@@ -30,7 +30,9 @@ export class PrismaObjectRef<
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
- value.forEach((val) => void brandWithType(val, this.name as never));
33
+ for (const val of value) {
34
+ brandWithType(val, this.name as never);
35
+ }
34
36
 
35
37
  return value as never;
36
38
  }