houdini 0.15.9 โ†’ 0.16.0-next.2

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 (542) hide show
  1. package/.eslintrc.cjs +36 -0
  2. package/.husky/pre-commit +0 -0
  3. package/.prettierignore +0 -1
  4. package/.prettierrc +4 -1
  5. package/CHANGELOG.md +40 -0
  6. package/README.md +8 -7
  7. package/build/cmd/generate.js +190 -96
  8. package/build/cmd/generators/artifacts/fieldKey.js +1 -4
  9. package/build/cmd/generators/artifacts/index.d.ts +1 -1
  10. package/build/cmd/generators/artifacts/index.js +17 -23
  11. package/build/cmd/generators/artifacts/indexFile.js +2 -1
  12. package/build/cmd/generators/artifacts/inputs.js +1 -2
  13. package/build/cmd/generators/artifacts/operations.d.ts +1 -1
  14. package/build/cmd/generators/artifacts/operations.js +3 -3
  15. package/build/cmd/generators/artifacts/selection.d.ts +1 -1
  16. package/build/cmd/generators/artifacts/selection.js +4 -6
  17. package/build/cmd/generators/artifacts/utils.js +3 -2
  18. package/build/cmd/generators/definitions/enums.js +7 -7
  19. package/build/cmd/generators/definitions/index.js +3 -3
  20. package/build/cmd/generators/index.d.ts +1 -0
  21. package/build/cmd/generators/index.js +3 -1
  22. package/build/cmd/generators/kit/index.d.ts +3 -0
  23. package/build/cmd/generators/kit/index.js +160 -0
  24. package/build/cmd/generators/persistedQueries/index.js +1 -2
  25. package/build/cmd/generators/runtime/adapter.js +2 -44
  26. package/build/cmd/generators/runtime/copyRuntime.js +79 -44
  27. package/build/cmd/generators/runtime/index.js +1 -6
  28. package/build/cmd/generators/runtime/indexFile.js +26 -4
  29. package/build/cmd/generators/stores/fragment.js +45 -26
  30. package/build/cmd/generators/stores/index.js +3 -3
  31. package/build/cmd/generators/stores/mutation.js +25 -16
  32. package/build/cmd/generators/stores/query.js +57 -54
  33. package/build/cmd/generators/stores/subscription.js +24 -45
  34. package/build/cmd/generators/typescript/addReferencedInputTypes.d.ts +1 -1
  35. package/build/cmd/generators/typescript/addReferencedInputTypes.js +2 -4
  36. package/build/cmd/generators/typescript/index.js +9 -22
  37. package/build/cmd/generators/typescript/inlineType.d.ts +1 -1
  38. package/build/cmd/generators/typescript/inlineType.js +6 -8
  39. package/build/cmd/generators/typescript/typeReference.d.ts +1 -1
  40. package/build/cmd/generators/typescript/typeReference.js +1 -2
  41. package/build/cmd/generators/typescript/types.d.ts +2 -2
  42. package/build/cmd/generators/typescript/types.js +1 -2
  43. package/build/cmd/init.d.ts +1 -1
  44. package/build/cmd/init.js +203 -140
  45. package/build/cmd/main.js +33 -48
  46. package/build/cmd/pullSchema.d.ts +3 -0
  47. package/build/cmd/pullSchema.js +34 -0
  48. package/build/cmd/testUtils.d.ts +2 -2
  49. package/build/cmd/testUtils.js +3 -4
  50. package/build/cmd/transforms/addID.js +0 -2
  51. package/build/cmd/transforms/composeQueries.js +3 -3
  52. package/build/cmd/transforms/fragmentVariables.d.ts +1 -1
  53. package/build/cmd/transforms/fragmentVariables.js +17 -7
  54. package/build/cmd/transforms/list.js +3 -7
  55. package/build/cmd/transforms/paginate.js +3 -5
  56. package/build/cmd/transforms/schema.js +11 -5
  57. package/build/cmd/transforms/typename.js +0 -2
  58. package/build/cmd/types.d.ts +1 -10
  59. package/build/cmd/types.js +0 -2
  60. package/build/cmd/utils/cleanupFiles.js +4 -5
  61. package/build/cmd/utils/flattenSelections.js +3 -2
  62. package/build/cmd/utils/index.d.ts +1 -3
  63. package/build/cmd/utils/index.js +1 -3
  64. package/build/cmd/utils/introspection.d.ts +2 -0
  65. package/build/cmd/utils/{writeSchema.js โ†’ introspection.js} +7 -15
  66. package/build/cmd/utils/moduleExport.d.ts +1 -1
  67. package/build/cmd/utils/moduleExport.js +1 -2
  68. package/build/cmd/utils/murmur.js +0 -1
  69. package/build/cmd/validators/forbiddenNames.d.ts +3 -0
  70. package/build/cmd/validators/forbiddenNames.js +33 -0
  71. package/build/cmd/validators/index.d.ts +1 -0
  72. package/build/cmd/validators/index.js +3 -1
  73. package/build/cmd/validators/noIDAlias.js +2 -4
  74. package/build/cmd/validators/typeCheck.d.ts +1 -1
  75. package/build/cmd/validators/typeCheck.js +37 -18
  76. package/build/cmd/validators/uniqueNames.js +8 -4
  77. package/build/cmd.js +159776 -109522
  78. package/build/common/config.d.ts +53 -11
  79. package/build/common/config.js +306 -112
  80. package/build/common/error.d.ts +9 -0
  81. package/build/common/error.js +18 -0
  82. package/build/common/extractLoadFunction.d.ts +4 -0
  83. package/build/common/extractLoadFunction.js +214 -0
  84. package/build/common/fs.d.ts +17 -0
  85. package/build/common/fs.js +144 -0
  86. package/build/common/graphql.d.ts +3 -1
  87. package/build/common/graphql.js +39 -10
  88. package/build/common/imports.d.ts +5 -2
  89. package/build/common/imports.js +2 -4
  90. package/build/common/index.d.ts +4 -0
  91. package/build/common/index.js +3 -0
  92. package/build/common/parse.d.ts +7 -5
  93. package/build/common/parse.js +35 -30
  94. package/build/common/pipeline.d.ts +1 -1
  95. package/build/common/pipeline.js +1 -1
  96. package/build/common/tests.d.ts +2 -3
  97. package/build/common/tests.js +5 -168
  98. package/build/common/types.d.ts +10 -5
  99. package/build/{preprocess/utils/walkTaggedDocuments.d.ts โ†’ common/walk.d.ts} +6 -8
  100. package/build/{preprocess/utils/walkTaggedDocuments.js โ†’ common/walk.js} +9 -45
  101. package/build/preprocess/index.d.ts +0 -1
  102. package/build/preprocess/index.js +51 -3
  103. package/build/preprocess-cjs/index.js +133267 -47217
  104. package/build/preprocess-esm/index.js +134778 -48734
  105. package/build/runtime/adapter.d.ts +0 -4
  106. package/build/runtime/adapter.js +1 -14
  107. package/build/runtime/cache/cache.d.ts +1 -1
  108. package/build/runtime/cache/cache.js +15 -15
  109. package/build/runtime/cache/stuff.d.ts +1 -1
  110. package/build/runtime/cache/subscription.d.ts +1 -1
  111. package/build/runtime/index.d.ts +2 -2
  112. package/build/runtime/index.js +16 -2
  113. package/build/runtime/inline/fragment.d.ts +6 -12
  114. package/build/runtime/inline/fragment.js +49 -78
  115. package/build/runtime/inline/index.d.ts +0 -3
  116. package/build/runtime/inline/index.js +1 -8
  117. package/build/runtime/lib/config.d.ts +46 -20
  118. package/build/runtime/lib/config.js +34 -1
  119. package/build/runtime/lib/context.d.ts +1 -3
  120. package/build/runtime/lib/context.js +3 -70
  121. package/build/runtime/lib/index.d.ts +6 -1
  122. package/build/runtime/lib/index.js +49 -3
  123. package/build/runtime/lib/network.d.ts +19 -32
  124. package/build/runtime/lib/network.js +53 -169
  125. package/build/runtime/lib/scalars.d.ts +5 -7
  126. package/build/runtime/lib/scalars.js +13 -10
  127. package/build/runtime/lib/test.d.ts +4 -0
  128. package/build/runtime/lib/test.js +189 -0
  129. package/build/runtime/lib/types.d.ts +15 -135
  130. package/build/runtime/lib/types.js +5 -5
  131. package/build/runtime/stores/fragment.d.ts +17 -10
  132. package/build/runtime/stores/fragment.js +25 -79
  133. package/build/runtime/stores/index.d.ts +5 -4
  134. package/build/runtime/stores/index.js +23 -8
  135. package/build/runtime/stores/mutation.d.ts +28 -4
  136. package/build/runtime/stores/mutation.js +45 -52
  137. package/build/runtime/stores/pagination/cursor.d.ts +29 -0
  138. package/build/runtime/stores/pagination/cursor.js +162 -0
  139. package/build/runtime/stores/pagination/fetch.d.ts +3 -0
  140. package/build/runtime/stores/pagination/fetch.js +2 -0
  141. package/build/runtime/stores/pagination/fragment.d.ts +154 -0
  142. package/build/runtime/stores/pagination/fragment.js +144 -0
  143. package/build/runtime/stores/pagination/index.d.ts +2 -0
  144. package/build/runtime/stores/pagination/index.js +11 -0
  145. package/build/runtime/stores/pagination/offset.d.ts +28 -0
  146. package/build/runtime/stores/pagination/offset.js +98 -0
  147. package/build/runtime/stores/pagination/pageInfo.d.ts +13 -0
  148. package/build/runtime/stores/pagination/pageInfo.js +54 -0
  149. package/build/runtime/stores/pagination/query.d.ts +42 -0
  150. package/build/runtime/stores/pagination/query.js +75 -0
  151. package/build/runtime/stores/query.d.ts +102 -24
  152. package/build/runtime/stores/query.js +246 -351
  153. package/build/runtime/stores/store.d.ts +2 -0
  154. package/build/runtime/stores/store.js +6 -0
  155. package/build/runtime/stores/subscription.d.ts +15 -4
  156. package/build/runtime/stores/subscription.js +80 -79
  157. package/build/runtime-cjs/adapter.d.ts +0 -4
  158. package/build/runtime-cjs/adapter.js +1 -14
  159. package/build/runtime-cjs/cache/cache.d.ts +1 -1
  160. package/build/runtime-cjs/cache/cache.js +15 -15
  161. package/build/runtime-cjs/cache/stuff.d.ts +1 -1
  162. package/build/runtime-cjs/cache/subscription.d.ts +1 -1
  163. package/build/runtime-cjs/index.d.ts +2 -2
  164. package/build/runtime-cjs/index.js +16 -2
  165. package/build/runtime-cjs/inline/fragment.d.ts +6 -12
  166. package/build/runtime-cjs/inline/fragment.js +49 -78
  167. package/build/runtime-cjs/inline/index.d.ts +0 -3
  168. package/build/runtime-cjs/inline/index.js +1 -8
  169. package/build/runtime-cjs/lib/config.d.ts +46 -20
  170. package/build/runtime-cjs/lib/config.js +34 -1
  171. package/build/runtime-cjs/lib/context.d.ts +1 -3
  172. package/build/runtime-cjs/lib/context.js +3 -70
  173. package/build/runtime-cjs/lib/index.d.ts +6 -1
  174. package/build/runtime-cjs/lib/index.js +49 -3
  175. package/build/runtime-cjs/lib/network.d.ts +19 -32
  176. package/build/runtime-cjs/lib/network.js +53 -169
  177. package/build/runtime-cjs/lib/scalars.d.ts +5 -7
  178. package/build/runtime-cjs/lib/scalars.js +13 -10
  179. package/build/runtime-cjs/lib/test.d.ts +4 -0
  180. package/build/runtime-cjs/lib/test.js +189 -0
  181. package/build/runtime-cjs/lib/types.d.ts +15 -135
  182. package/build/runtime-cjs/lib/types.js +5 -5
  183. package/build/runtime-cjs/meta.json +1 -0
  184. package/build/runtime-cjs/stores/fragment.d.ts +17 -10
  185. package/build/runtime-cjs/stores/fragment.js +25 -79
  186. package/build/runtime-cjs/stores/index.d.ts +5 -4
  187. package/build/runtime-cjs/stores/index.js +23 -8
  188. package/build/runtime-cjs/stores/mutation.d.ts +28 -4
  189. package/build/runtime-cjs/stores/mutation.js +45 -52
  190. package/build/runtime-cjs/stores/pagination/cursor.d.ts +29 -0
  191. package/build/runtime-cjs/stores/pagination/cursor.js +162 -0
  192. package/build/runtime-cjs/stores/pagination/fetch.d.ts +3 -0
  193. package/build/{preprocess/types.js โ†’ runtime-cjs/stores/pagination/fetch.js} +0 -0
  194. package/build/runtime-cjs/stores/pagination/fragment.d.ts +154 -0
  195. package/build/runtime-cjs/stores/pagination/fragment.js +144 -0
  196. package/build/runtime-cjs/stores/pagination/index.d.ts +2 -0
  197. package/build/runtime-cjs/stores/pagination/index.js +11 -0
  198. package/build/runtime-cjs/stores/pagination/offset.d.ts +28 -0
  199. package/build/runtime-cjs/stores/pagination/offset.js +98 -0
  200. package/build/runtime-cjs/stores/pagination/pageInfo.d.ts +13 -0
  201. package/build/runtime-cjs/stores/pagination/pageInfo.js +54 -0
  202. package/build/runtime-cjs/stores/pagination/query.d.ts +42 -0
  203. package/build/runtime-cjs/stores/pagination/query.js +75 -0
  204. package/build/runtime-cjs/stores/query.d.ts +102 -24
  205. package/build/runtime-cjs/stores/query.js +246 -351
  206. package/build/runtime-cjs/stores/store.d.ts +2 -0
  207. package/build/runtime-cjs/stores/store.js +6 -0
  208. package/build/runtime-cjs/stores/subscription.d.ts +15 -4
  209. package/build/runtime-cjs/stores/subscription.js +80 -79
  210. package/build/runtime-esm/adapter.d.ts +0 -4
  211. package/build/runtime-esm/adapter.js +0 -11
  212. package/build/runtime-esm/cache/cache.d.ts +1 -1
  213. package/build/runtime-esm/cache/cache.js +15 -15
  214. package/build/runtime-esm/cache/stuff.d.ts +1 -1
  215. package/build/runtime-esm/cache/subscription.d.ts +1 -1
  216. package/build/runtime-esm/index.d.ts +2 -2
  217. package/build/runtime-esm/index.js +17 -2
  218. package/build/runtime-esm/inline/fragment.d.ts +6 -12
  219. package/build/runtime-esm/inline/fragment.js +26 -79
  220. package/build/runtime-esm/inline/index.d.ts +0 -3
  221. package/build/runtime-esm/inline/index.js +0 -3
  222. package/build/runtime-esm/lib/config.d.ts +46 -20
  223. package/build/runtime-esm/lib/config.js +9 -0
  224. package/build/runtime-esm/lib/context.d.ts +1 -3
  225. package/build/runtime-esm/lib/context.js +2 -45
  226. package/build/runtime-esm/lib/index.d.ts +6 -1
  227. package/build/runtime-esm/lib/index.js +47 -1
  228. package/build/runtime-esm/lib/network.d.ts +19 -32
  229. package/build/runtime-esm/lib/network.js +51 -165
  230. package/build/runtime-esm/lib/scalars.d.ts +5 -7
  231. package/build/runtime-esm/lib/scalars.js +13 -10
  232. package/build/runtime-esm/lib/test.d.ts +4 -0
  233. package/build/runtime-esm/lib/test.js +183 -0
  234. package/build/runtime-esm/lib/types.d.ts +15 -135
  235. package/build/runtime-esm/lib/types.js +4 -4
  236. package/build/runtime-esm/meta.json +1 -0
  237. package/build/runtime-esm/stores/fragment.d.ts +17 -10
  238. package/build/runtime-esm/stores/fragment.js +24 -78
  239. package/build/runtime-esm/stores/index.d.ts +5 -4
  240. package/build/runtime-esm/stores/index.js +5 -4
  241. package/build/runtime-esm/stores/mutation.d.ts +28 -4
  242. package/build/runtime-esm/stores/mutation.js +45 -52
  243. package/build/runtime-esm/stores/pagination/cursor.d.ts +29 -0
  244. package/build/runtime-esm/stores/pagination/cursor.js +156 -0
  245. package/build/runtime-esm/stores/pagination/fetch.d.ts +3 -0
  246. package/build/{preprocess/test.d.ts โ†’ runtime-esm/stores/pagination/fetch.js} +0 -0
  247. package/build/runtime-esm/stores/pagination/fragment.d.ts +154 -0
  248. package/build/runtime-esm/stores/pagination/fragment.js +139 -0
  249. package/build/runtime-esm/stores/pagination/index.d.ts +2 -0
  250. package/build/runtime-esm/stores/pagination/index.js +2 -0
  251. package/build/runtime-esm/stores/pagination/offset.d.ts +28 -0
  252. package/build/runtime-esm/stores/pagination/offset.js +92 -0
  253. package/build/runtime-esm/stores/pagination/pageInfo.d.ts +13 -0
  254. package/build/runtime-esm/stores/pagination/pageInfo.js +48 -0
  255. package/build/runtime-esm/stores/pagination/query.d.ts +42 -0
  256. package/build/runtime-esm/stores/pagination/query.js +69 -0
  257. package/build/runtime-esm/stores/query.d.ts +102 -24
  258. package/build/runtime-esm/stores/query.js +247 -350
  259. package/build/runtime-esm/stores/store.d.ts +2 -0
  260. package/build/runtime-esm/stores/store.js +2 -0
  261. package/build/runtime-esm/stores/subscription.d.ts +15 -4
  262. package/build/runtime-esm/stores/subscription.js +79 -77
  263. package/build/vite/ast.d.ts +7 -0
  264. package/build/vite/ast.js +21 -0
  265. package/build/vite/fsPatch.d.ts +2 -0
  266. package/build/vite/fsPatch.js +146 -0
  267. package/build/vite/imports.d.ts +48 -0
  268. package/build/vite/imports.js +83 -0
  269. package/build/vite/index.d.ts +5 -0
  270. package/build/vite/index.js +55 -0
  271. package/build/vite/manifest.d.ts +3 -0
  272. package/build/vite/manifest.js +60 -0
  273. package/build/vite/plugin.d.ts +10 -0
  274. package/build/vite/plugin.js +61 -0
  275. package/build/vite/schema.d.ts +2 -0
  276. package/build/vite/schema.js +60 -0
  277. package/build/vite/tests.d.ts +16 -0
  278. package/build/vite/tests.js +88 -0
  279. package/build/vite/transforms/index.d.ts +5 -0
  280. package/build/vite/transforms/index.js +105 -0
  281. package/build/vite/transforms/kit.d.ts +3 -0
  282. package/build/vite/transforms/kit.js +303 -0
  283. package/build/vite/transforms/query.d.ts +11 -0
  284. package/build/vite/transforms/query.js +177 -0
  285. package/build/vite/transforms/reactive.d.ts +3 -0
  286. package/build/vite/transforms/reactive.js +117 -0
  287. package/build/vite/transforms/tags.d.ts +3 -0
  288. package/build/{preprocess/utils/identifiers.js โ†’ vite/transforms/tags.js} +20 -4
  289. package/build/vite/watch-and-run.d.ts +45 -0
  290. package/build/vite/watch-and-run.js +148 -0
  291. package/build/vite-cjs/index.js +162495 -0
  292. package/build/vite-esm/index.js +162456 -0
  293. package/package.json +133 -112
  294. package/pnpm-workspace.yaml +1 -0
  295. package/rollup.config.js +12 -11
  296. package/runtimeMeta.js +11 -0
  297. package/site/package.json +11 -12
  298. package/site/src/app.d.ts +2 -5
  299. package/site/src/components/APIShowcase.svelte +7 -5
  300. package/site/src/components/Highlight.svelte +12 -0
  301. package/site/src/components/index.js +1 -1
  302. package/site/src/lib/highlight.js +663 -4
  303. package/site/src/lib/loadContent.js +81 -90
  304. package/site/src/lib/loadOutline.js +78 -96
  305. package/site/src/routes/_content.js +1 -1
  306. package/site/src/routes/_page.svelte +2 -4
  307. package/site/src/routes/api/cli.svx +17 -4
  308. package/site/src/routes/api/config.svx +19 -17
  309. package/site/src/routes/api/{fragment/inline.svx โ†’ fragments.svx} +53 -34
  310. package/site/src/routes/api/graphql.svx +7 -11
  311. package/site/src/routes/api/{mutation/inline.svx โ†’ mutation.svx} +76 -51
  312. package/site/src/routes/api/routes.svx +447 -0
  313. package/site/src/routes/api/{subscription/inline.svx โ†’ subscription.svx} +61 -8
  314. package/site/src/routes/api/vite.svx +34 -0
  315. package/site/src/routes/api/welcome.svx +23 -25
  316. package/site/src/routes/guides/authentication.svx +1 -1
  317. package/site/src/routes/guides/caching-data.svx +2 -2
  318. package/site/src/routes/guides/contributing.svx +73 -13
  319. package/site/src/routes/guides/faq.svx +42 -38
  320. package/site/src/routes/guides/migrating-to-016.svx +281 -0
  321. package/site/src/routes/guides/pagination.svx +69 -42
  322. package/site/src/routes/guides/persisted-queries.svx +4 -4
  323. package/site/src/routes/guides/release-notes.svx +308 -0
  324. package/site/src/routes/guides/setting-up-your-project.svx +35 -59
  325. package/site/src/routes/guides/typescript.svx +59 -49
  326. package/site/src/routes/guides/working-with-graphql.svx +377 -108
  327. package/site/src/routes/index.svelte +16 -22
  328. package/site/src/routes/intro/fetching-data.svx +41 -50
  329. package/site/src/routes/intro/fragments.svx +47 -63
  330. package/site/src/routes/intro/mutations.svx +6 -8
  331. package/site/src/routes/intro/pagination.svx +18 -23
  332. package/site/static/styles/code.css +453 -61
  333. package/site/static/styles/md.css +11 -4
  334. package/site/svelte.config.js +2 -29
  335. package/site/vite.config.js +2 -5
  336. package/src/cmd/generate.ts +246 -115
  337. package/src/cmd/generators/artifacts/fieldKey.ts +4 -4
  338. package/src/cmd/generators/artifacts/index.ts +28 -26
  339. package/src/cmd/generators/artifacts/indexFile.ts +4 -5
  340. package/src/cmd/generators/artifacts/inputs.ts +3 -4
  341. package/src/cmd/generators/artifacts/operations.ts +5 -5
  342. package/src/cmd/generators/artifacts/selection.ts +8 -9
  343. package/src/cmd/generators/artifacts/utils.ts +4 -2
  344. package/src/cmd/generators/definitions/enums.ts +12 -11
  345. package/src/cmd/generators/definitions/index.ts +1 -4
  346. package/src/cmd/generators/index.ts +1 -0
  347. package/src/cmd/generators/kit/index.ts +162 -0
  348. package/src/cmd/generators/persistedQueries/index.ts +3 -3
  349. package/src/cmd/generators/runtime/adapter.ts +2 -47
  350. package/src/cmd/generators/runtime/copyRuntime.ts +72 -56
  351. package/src/cmd/generators/runtime/index.ts +1 -7
  352. package/src/cmd/generators/runtime/indexFile.ts +5 -5
  353. package/src/cmd/generators/stores/fragment.ts +49 -33
  354. package/src/cmd/generators/stores/index.ts +2 -3
  355. package/src/cmd/generators/stores/mutation.ts +25 -15
  356. package/src/cmd/generators/stores/query.ts +59 -33
  357. package/src/cmd/generators/stores/subscription.ts +25 -24
  358. package/src/cmd/generators/typescript/addReferencedInputTypes.ts +5 -6
  359. package/src/cmd/generators/typescript/index.ts +12 -68
  360. package/src/cmd/generators/typescript/inlineType.ts +15 -14
  361. package/src/cmd/generators/typescript/typeReference.ts +3 -4
  362. package/src/cmd/generators/typescript/types.ts +3 -3
  363. package/src/cmd/init.ts +193 -138
  364. package/src/cmd/main.ts +53 -62
  365. package/src/cmd/pullSchema.ts +41 -0
  366. package/src/cmd/testUtils.ts +7 -9
  367. package/src/cmd/transforms/addID.ts +1 -2
  368. package/src/cmd/transforms/composeQueries.ts +4 -5
  369. package/src/cmd/transforms/fragmentVariables.ts +18 -10
  370. package/src/cmd/transforms/list.ts +108 -106
  371. package/src/cmd/transforms/paginate.ts +36 -36
  372. package/src/cmd/transforms/schema.ts +14 -7
  373. package/src/cmd/transforms/typename.ts +1 -2
  374. package/src/cmd/types.ts +2 -12
  375. package/src/cmd/utils/cleanupFiles.ts +3 -3
  376. package/src/cmd/utils/flattenSelections.ts +4 -5
  377. package/src/cmd/utils/graphql.ts +1 -0
  378. package/src/cmd/utils/index.ts +1 -3
  379. package/src/cmd/utils/{writeSchema.ts โ†’ introspection.ts} +7 -11
  380. package/src/cmd/utils/moduleExport.ts +3 -4
  381. package/src/cmd/utils/murmur.ts +0 -1
  382. package/src/cmd/validators/forbiddenNames.ts +45 -0
  383. package/src/cmd/validators/index.ts +1 -0
  384. package/src/cmd/validators/noIDAlias.ts +10 -9
  385. package/src/cmd/validators/typeCheck.ts +69 -36
  386. package/src/cmd/validators/uniqueNames.ts +14 -9
  387. package/src/common/config.ts +414 -135
  388. package/src/common/error.ts +24 -0
  389. package/src/common/extractLoadFunction.ts +246 -0
  390. package/src/common/fs.ts +155 -0
  391. package/src/common/graphql.ts +46 -9
  392. package/src/common/imports.ts +11 -9
  393. package/src/common/index.ts +5 -0
  394. package/src/common/parse.ts +38 -37
  395. package/src/common/pipeline.ts +4 -3
  396. package/src/common/tests.ts +4 -167
  397. package/src/common/types.ts +12 -5
  398. package/src/{preprocess/utils/walkTaggedDocuments.ts โ†’ common/walk.ts} +15 -60
  399. package/src/preprocess/index.ts +31 -3
  400. package/src/runtime/adapter.ts +0 -12
  401. package/src/runtime/cache/cache.ts +16 -17
  402. package/src/runtime/cache/lists.ts +0 -1
  403. package/src/runtime/cache/stuff.ts +1 -1
  404. package/src/runtime/cache/subscription.ts +2 -2
  405. package/src/runtime/index.ts +18 -3
  406. package/src/runtime/inline/fragment.ts +48 -119
  407. package/src/runtime/inline/index.ts +0 -3
  408. package/src/runtime/lib/config.ts +62 -21
  409. package/src/runtime/lib/context.ts +2 -50
  410. package/src/runtime/lib/index.ts +68 -1
  411. package/src/runtime/lib/network.ts +72 -251
  412. package/src/runtime/lib/scalars.ts +68 -63
  413. package/src/runtime/lib/test.ts +189 -0
  414. package/src/runtime/lib/types.ts +30 -176
  415. package/src/runtime/stores/fragment.ts +39 -119
  416. package/src/runtime/stores/index.ts +5 -4
  417. package/src/runtime/stores/mutation.ts +72 -69
  418. package/src/runtime/stores/pagination/cursor.ts +257 -0
  419. package/src/runtime/stores/pagination/fetch.ts +6 -0
  420. package/src/runtime/stores/pagination/fragment.ts +232 -0
  421. package/src/runtime/stores/pagination/index.ts +7 -0
  422. package/src/runtime/stores/pagination/offset.ts +152 -0
  423. package/src/runtime/stores/pagination/pageInfo.ts +67 -0
  424. package/src/runtime/stores/pagination/query.ts +130 -0
  425. package/src/runtime/stores/query.ts +392 -458
  426. package/src/runtime/stores/store.ts +3 -0
  427. package/src/runtime/stores/subscription.ts +88 -89
  428. package/src/vite/ast.ts +29 -0
  429. package/src/vite/fsPatch.ts +141 -0
  430. package/src/vite/imports.ts +141 -0
  431. package/src/vite/index.ts +62 -0
  432. package/src/vite/manifest.ts +44 -0
  433. package/src/vite/plugin.ts +75 -0
  434. package/src/vite/schema.ts +73 -0
  435. package/src/vite/tests.ts +147 -0
  436. package/src/vite/transforms/index.ts +93 -0
  437. package/src/vite/transforms/kit.ts +452 -0
  438. package/src/vite/transforms/query.ts +262 -0
  439. package/src/vite/transforms/reactive.ts +122 -0
  440. package/src/vite/transforms/tags.ts +30 -0
  441. package/src/vite/watch-and-run.ts +224 -0
  442. package/typeModule.js +19 -0
  443. package/vite.config.ts +9 -0
  444. package/{jest.d.ts โ†’ vite.d.ts} +1 -1
  445. package/{jest.setup.js โ†’ vitest.setup.ts} +32 -28
  446. package/.yarnrc.yml +0 -3
  447. package/build/cmd/generators/runtime/meta.d.ts +0 -2
  448. package/build/cmd/generators/runtime/meta.js +0 -10
  449. package/build/cmd/generators/stores/pagination.d.ts +0 -8
  450. package/build/cmd/generators/stores/pagination.js +0 -50
  451. package/build/cmd/utils/readFile.d.ts +0 -1
  452. package/build/cmd/utils/readFile.js +0 -15
  453. package/build/cmd/utils/writeFile.d.ts +0 -1
  454. package/build/cmd/utils/writeFile.js +0 -16
  455. package/build/cmd/utils/writeSchema.d.ts +0 -2
  456. package/build/preprocess/test.js +0 -255
  457. package/build/preprocess/transforms/fragment.d.ts +0 -3
  458. package/build/preprocess/transforms/fragment.js +0 -122
  459. package/build/preprocess/transforms/index.d.ts +0 -9
  460. package/build/preprocess/transforms/index.js +0 -130
  461. package/build/preprocess/transforms/module.d.ts +0 -3
  462. package/build/preprocess/transforms/module.js +0 -49
  463. package/build/preprocess/transforms/mutation.d.ts +0 -3
  464. package/build/preprocess/transforms/mutation.js +0 -63
  465. package/build/preprocess/transforms/query.d.ts +0 -3
  466. package/build/preprocess/transforms/query.js +0 -463
  467. package/build/preprocess/transforms/subscription.d.ts +0 -3
  468. package/build/preprocess/transforms/subscription.js +0 -71
  469. package/build/preprocess/types.d.ts +0 -8
  470. package/build/preprocess/utils/artifactIdentifier.d.ts +0 -3
  471. package/build/preprocess/utils/artifactIdentifier.js +0 -6
  472. package/build/preprocess/utils/identifiers.d.ts +0 -4
  473. package/build/preprocess/utils/index.d.ts +0 -4
  474. package/build/preprocess/utils/index.js +0 -25
  475. package/build/preprocess/utils/preprocessorTest.d.ts +0 -8
  476. package/build/preprocess/utils/preprocessorTest.js +0 -61
  477. package/build/runtime/inline/mutation.d.ts +0 -5
  478. package/build/runtime/inline/mutation.js +0 -21
  479. package/build/runtime/inline/query.d.ts +0 -21
  480. package/build/runtime/inline/query.js +0 -47
  481. package/build/runtime/inline/subscription.d.ts +0 -5
  482. package/build/runtime/inline/subscription.js +0 -27
  483. package/build/runtime/lib/pagination.d.ts +0 -88
  484. package/build/runtime/lib/pagination.js +0 -463
  485. package/build/runtime/lib/session.d.ts +0 -9
  486. package/build/runtime/lib/session.js +0 -47
  487. package/build/runtime-cjs/inline/mutation.d.ts +0 -5
  488. package/build/runtime-cjs/inline/mutation.js +0 -21
  489. package/build/runtime-cjs/inline/query.d.ts +0 -21
  490. package/build/runtime-cjs/inline/query.js +0 -47
  491. package/build/runtime-cjs/inline/subscription.d.ts +0 -5
  492. package/build/runtime-cjs/inline/subscription.js +0 -27
  493. package/build/runtime-cjs/lib/pagination.d.ts +0 -88
  494. package/build/runtime-cjs/lib/pagination.js +0 -463
  495. package/build/runtime-cjs/lib/session.d.ts +0 -9
  496. package/build/runtime-cjs/lib/session.js +0 -47
  497. package/build/runtime-esm/inline/mutation.d.ts +0 -5
  498. package/build/runtime-esm/inline/mutation.js +0 -17
  499. package/build/runtime-esm/inline/query.d.ts +0 -21
  500. package/build/runtime-esm/inline/query.js +0 -42
  501. package/build/runtime-esm/inline/subscription.d.ts +0 -5
  502. package/build/runtime-esm/inline/subscription.js +0 -23
  503. package/build/runtime-esm/lib/pagination.d.ts +0 -88
  504. package/build/runtime-esm/lib/pagination.js +0 -458
  505. package/build/runtime-esm/lib/session.d.ts +0 -9
  506. package/build/runtime-esm/lib/session.js +0 -42
  507. package/jest.config.js +0 -19
  508. package/site/src/components/HeaderWithMode.svelte +0 -53
  509. package/site/src/hooks.ts +0 -11
  510. package/site/src/lib/graphql-language.js +0 -45
  511. package/site/src/lib/mode.js +0 -20
  512. package/site/src/routes/api/fragment/store.svx +0 -166
  513. package/site/src/routes/api/mutation/store.svx +0 -99
  514. package/site/src/routes/api/preprocessor.svx +0 -30
  515. package/site/src/routes/api/query/inline.svx +0 -219
  516. package/site/src/routes/api/query/store.svx +0 -299
  517. package/site/src/routes/api/subscription/store.svx +0 -37
  518. package/site/src/routes/guides/migrating-to-0.15.0.svx +0 -92
  519. package/site/src/routes/setMode.ts +0 -12
  520. package/site/src/sections/subscription-client.svx +0 -93
  521. package/src/cmd/generators/runtime/meta.ts +0 -13
  522. package/src/cmd/generators/stores/pagination.ts +0 -60
  523. package/src/cmd/utils/readFile.ts +0 -8
  524. package/src/cmd/utils/writeFile.ts +0 -10
  525. package/src/preprocess/test.ts +0 -272
  526. package/src/preprocess/transforms/fragment.ts +0 -137
  527. package/src/preprocess/transforms/index.ts +0 -168
  528. package/src/preprocess/transforms/module.ts +0 -39
  529. package/src/preprocess/transforms/mutation.ts +0 -49
  530. package/src/preprocess/transforms/query.ts +0 -835
  531. package/src/preprocess/transforms/subscription.ts +0 -60
  532. package/src/preprocess/types.ts +0 -10
  533. package/src/preprocess/utils/artifactIdentifier.ts +0 -3
  534. package/src/preprocess/utils/identifiers.ts +0 -7
  535. package/src/preprocess/utils/index.ts +0 -4
  536. package/src/preprocess/utils/preprocessorTest.ts +0 -44
  537. package/src/runtime/inline/mutation.ts +0 -28
  538. package/src/runtime/inline/query.ts +0 -69
  539. package/src/runtime/inline/subscription.ts +0 -38
  540. package/src/runtime/lib/pagination.ts +0 -680
  541. package/src/runtime/lib/session.ts +0 -60
  542. package/typeModule.sh +0 -25
package/.eslintrc.cjs ADDED
@@ -0,0 +1,36 @@
1
+ module.exports = {
2
+ root: true,
3
+ extends: '@theguild',
4
+ rules: {
5
+ '@typescript-eslint/no-unused-vars': 'off',
6
+ '@typescript-eslint/ban-ts-comment': 'off',
7
+ '@typescript-eslint/no-non-null-assertion': 'off',
8
+ '@typescript-eslint/no-explicit-any': 'off',
9
+ '@typescript-eslint/no-empty-function': 'off',
10
+ '@typescript-eslint/ban-types': 'off',
11
+ '@typescript-eslint/no-inferrable-types': 'off',
12
+ '@typescript-eslint/prefer-as-const': 'off',
13
+ '@typescript-eslint/no-var-requires': 'off',
14
+ 'unicorn/no-lonely-if': 'off',
15
+ 'unicorn/filename-case': 'off',
16
+ 'unicorn/no-instanceof-array': 'off',
17
+ 'unicorn/prefer-includes': 'off',
18
+ 'import/no-default-export': 'off',
19
+ 'sonarjs/no-gratuitous-expressions': 'off',
20
+ 'no-lonely-if': 'off',
21
+ 'no-console': 'off',
22
+ 'prefer-arrow-callback': 'off',
23
+ 'prefer-const': 'off',
24
+ 'no-else-return': 'off',
25
+ 'no-empty': 'off',
26
+ 'no-var': 'off',
27
+ 'no-undef': 'off',
28
+ 'object-shorthand': 'off',
29
+ // 'no-console': ['error', { allow: ['info', 'warn', 'error', 'time', 'timeEnd'] }],
30
+ },
31
+ ignorePatterns: ['integration', 'example', 'site'],
32
+ parserOptions: {
33
+ sourceType: 'module',
34
+ ecmaVersion: 2020,
35
+ },
36
+ }
package/.husky/pre-commit CHANGED
File without changes
package/.prettierignore CHANGED
@@ -1,4 +1,3 @@
1
- .yarn/
2
1
  **/build/**
3
2
  README.md
4
3
  .github/**
package/.prettierrc CHANGED
@@ -4,5 +4,8 @@
4
4
  "useTabs": true,
5
5
  "singleQuote": true,
6
6
  "printWidth": 100,
7
- "trailingComma": "es5"
7
+ "trailingComma": "es5",
8
+ "plugins": ["@trivago/prettier-plugin-sort-imports"],
9
+ "importOrder": ["<THIRD_PARTY_MODULES>", "^[./]"],
10
+ "importOrderSeparation": true
8
11
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
1
  # houdini
2
2
 
3
+ ## 0.16.0-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#483](https://github.com/HoudiniGraphql/houdini/pull/483) [`a69138a`](https://github.com/HoudiniGraphql/houdini/commit/a69138ae2908b0517cdbfe8b544b634e6f96df53) Thanks [@jycouet](https://github.com/jycouet)! - fix: check field existence before @list directive to have better error msg
8
+
9
+ ## 0.16.0-next.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#479](https://github.com/HoudiniGraphql/houdini/pull/479) [`9a9d376`](https://github.com/HoudiniGraphql/houdini/commit/9a9d376d7d707889a5ca77a5b98ebddcef7d6272) Thanks [@janvotava](https://github.com/janvotava)! - fix readDirSync patch (fixing file.isDirectory is not a function)
14
+
15
+ ## 0.16.0-next.0
16
+
17
+ ### โš ๏ธ Breaking Changes
18
+
19
+ - [#449](https://github.com/HoudiniGraphql/houdini/pull/449) [`59257d1`](https://github.com/HoudiniGraphql/houdini/commit/59257d1dffa6c1d9d250ba0964c6f1f0c35da048) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - remove inline document functions query, paginatedQuery, subscription, and mutation
20
+
21
+ * [#449](https://github.com/HoudiniGraphql/houdini/pull/449) [`59257d1`](https://github.com/HoudiniGraphql/houdini/commit/59257d1dffa6c1d9d250ba0964c6f1f0c35da048) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - renamed `generate --pull-header` to `generate --header` and `generate --persist-output` to `generate --output`
22
+
23
+ * [#449](https://github.com/HoudiniGraphql/houdini/pull/449) [`59257d1`](https://github.com/HoudiniGraphql/houdini/commit/59257d1dffa6c1d9d250ba0964c6f1f0c35da048) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - inverted argument order for inline fragments
24
+
25
+ * [#449](https://github.com/HoudiniGraphql/houdini/pull/449) [`59257d1`](https://github.com/HoudiniGraphql/houdini/commit/59257d1dffa6c1d9d250ba0964c6f1f0c35da048) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - Stores are now classes and need to be instantiated with `new MyQueryStore()`
26
+
27
+ - [#449](https://github.com/HoudiniGraphql/houdini/pull/449) [`59257d1`](https://github.com/HoudiniGraphql/houdini/commit/59257d1dffa6c1d9d250ba0964c6f1f0c35da048) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - query stores must now be passed to routes as props instead of globally imported
28
+
29
+ * [#449](https://github.com/HoudiniGraphql/houdini/pull/449) [`59257d1`](https://github.com/HoudiniGraphql/houdini/commit/59257d1dffa6c1d9d250ba0964c6f1f0c35da048) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - SvelteKit projects must now use `houdini/kit` as a vite plugin
30
+
31
+ - [#449](https://github.com/HoudiniGraphql/houdini/pull/449) [`59257d1`](https://github.com/HoudiniGraphql/houdini/commit/59257d1dffa6c1d9d250ba0964c6f1f0c35da048) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - `config.sourceGlob` has been renamed to `config.include` and is now optional. Also added `config.exclude` to filter out files matched by `config.include`
32
+
33
+ ### โœจ Features
34
+
35
+ - [#449](https://github.com/HoudiniGraphql/houdini/pull/449) [`59257d1`](https://github.com/HoudiniGraphql/houdini/commit/59257d1dffa6c1d9d250ba0964c6f1f0c35da048) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - added support for page queries
36
+
37
+ - [#449](https://github.com/HoudiniGraphql/houdini/pull/449) [`59257d1`](https://github.com/HoudiniGraphql/houdini/commit/59257d1dffa6c1d9d250ba0964c6f1f0c35da048) Thanks [@jycouet](https://github.com/jycouet)! - You can now define the prefix of your global stores with globalStorePrefix param in the config.
38
+
39
+ * [#449](https://github.com/HoudiniGraphql/houdini/pull/449) [`59257d1`](https://github.com/HoudiniGraphql/houdini/commit/59257d1dffa6c1d9d250ba0964c6f1f0c35da048) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - graphql tags return store references
40
+
41
+ - [#449](https://github.com/HoudiniGraphql/houdini/pull/449) [`59257d1`](https://github.com/HoudiniGraphql/houdini/commit/59257d1dffa6c1d9d250ba0964c6f1f0c35da048) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - add generated typedefs for route functions
42
+
3
43
  ## 0.15.9
4
44
 
5
45
  ### Patch Changes
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  <br />
6
6
 
7
7
  <strong>
8
- The disappearing GraphQL client for Sapper and SvelteKit.
8
+ The disappearing GraphQL client for SvelteKit.
9
9
  </strong>
10
10
  <br />
11
11
  <br />
@@ -14,18 +14,19 @@
14
14
 
15
15
  ```svelte
16
16
  <script>
17
- import { query, graphql } from '$houdini'
17
+ // src/routes/items/+page.svelte
18
+ import { graphql } from '$houdini'
18
19
 
19
- const { data } = query(graphql`
20
- query AllTodoItems {
20
+ const AllItems = graphql`
21
+ query AllItems {
21
22
  items {
22
23
  text
23
24
  }
24
25
  }
25
- `)
26
+ `
26
27
  </script>
27
28
 
28
- {#each $data.items as item}
29
+ {#each $AllItems.data.items as item}
29
30
  <div>{item.text}</div>
30
31
  {/each}
31
32
  ```
@@ -36,7 +37,7 @@
36
37
  - Normalized cache with declarative updates
37
38
  - Generated types
38
39
  - Subscriptions
39
- - Support for SvelteKit and Sapper
40
+ - Support for SvelteKit
40
41
  - Pagination (cursors **and** offsets)
41
42
 
42
43
  At its core, houdini seeks to enable a high quality developer experience
@@ -27,17 +27,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.runPipeline = void 0;
30
- // externals
31
30
  const glob_1 = __importDefault(require("glob"));
32
- const svelte = __importStar(require("svelte/compiler"));
33
- const promises_1 = __importDefault(require("fs/promises"));
34
31
  const graphql = __importStar(require("graphql"));
32
+ const minimatch_1 = __importDefault(require("minimatch"));
33
+ const path_1 = __importDefault(require("path"));
34
+ const svelte = __importStar(require("svelte/compiler"));
35
35
  const util_1 = require("util");
36
- // locals
37
36
  const common_1 = require("../common");
38
- const types_1 = require("./types");
39
- const transforms = __importStar(require("./transforms"));
40
37
  const generators = __importStar(require("./generators"));
38
+ const transforms = __importStar(require("./transforms"));
39
+ const types_1 = require("./types");
41
40
  const validators = __importStar(require("./validators"));
42
41
  // the main entry point of the compile script
43
42
  async function compile(config) {
@@ -65,92 +64,116 @@ async function runPipeline(config, docs) {
65
64
  new: [],
66
65
  deleted: [],
67
66
  };
68
- // notify the user we are starting the generation process
69
- if (config.logLevel !== common_1.LogLevel.Quiet) {
70
- console.log('๐ŸŽฉ Generating runtime...');
71
- }
72
67
  // the last version the runtime was generated with
73
68
  let previousVersion = '';
69
+ let newClientPath = false;
70
+ let newTimestamp = false;
71
+ const content = await (0, common_1.readFile)(config.metaFilePath);
72
+ if (content) {
73
+ try {
74
+ const parsed = JSON.parse(content);
75
+ previousVersion = parsed.version + parsed.createdOn;
76
+ newClientPath = parsed.client !== config.client;
77
+ // look up the source metadata (so we can figure out if the version actually changed)
78
+ const sourceMeta = await (0, common_1.readFile)(path_1.default.join(config.runtimeSource, 'meta.json'));
79
+ if (!sourceMeta) {
80
+ throw new Error('skip');
81
+ }
82
+ // if the two timestamps are not the same, we have a new version
83
+ newTimestamp = JSON.parse(sourceMeta).timestamp !== parsed.timestamp;
84
+ }
85
+ catch { }
86
+ }
87
+ // generate the runtime if the version changed, if its a new project, or they changed their client path
88
+ const generateRuntime = newTimestamp || newClientPath || !previousVersion;
89
+ // run the generate command before we print "๐ŸŽฉ Generating runtime..." because we don't know upfront artifactStats.
90
+ let error = null;
74
91
  try {
75
- const content = JSON.parse(await promises_1.default.readFile(config.metaFilePath, 'utf-8'));
76
- previousVersion = content.version;
92
+ await (0, common_1.runPipeline)(config, [
93
+ // validators
94
+ validators.typeCheck,
95
+ validators.uniqueNames,
96
+ validators.noIDAlias,
97
+ validators.forbiddenNames,
98
+ // transforms
99
+ transforms.internalSchema,
100
+ transforms.addID,
101
+ transforms.typename,
102
+ // list transform must go before fragment variables
103
+ // so that the mutation fragments are defined before they get mixed in
104
+ transforms.list,
105
+ // paginate transform needs to go before fragmentVariables
106
+ // so that the variable definitions get hashed
107
+ transforms.paginate,
108
+ transforms.fragmentVariables,
109
+ transforms.composeQueries,
110
+ // generators
111
+ // the runtime is a static thing most of the time. It only needs to be regenerated if
112
+ // the user is upgrading versions or the client path changed
113
+ generateRuntime ? generators.runtime : null,
114
+ generators.artifacts(artifactStats),
115
+ generators.typescript,
116
+ generators.persistOutput,
117
+ generators.definitions,
118
+ generators.stores,
119
+ // this has to go after runtime and artifacts
120
+ generators.kit,
121
+ ], docs);
77
122
  }
78
- catch { }
79
- // if the previous version is different from the current version
80
- const versionChanged = previousVersion && previousVersion !== 'HOUDINI_VERSION';
81
- await (0, common_1.runPipeline)(config, [
82
- // validators
83
- validators.typeCheck,
84
- validators.uniqueNames,
85
- validators.noIDAlias,
86
- // transforms
87
- transforms.internalSchema,
88
- transforms.addID,
89
- transforms.typename,
90
- // list transform must go before fragment variables
91
- // so that the mutation fragments are defined before they get mixed in
92
- transforms.list,
93
- // paginate transform needs to go before fragmentVariables
94
- // so that the variable definitions get hashed
95
- transforms.paginate,
96
- transforms.fragmentVariables,
97
- transforms.composeQueries,
98
- // generators
99
- generators.runtime,
100
- generators.artifacts(artifactStats),
101
- generators.typescript,
102
- generators.persistOutput,
103
- generators.definitions,
104
- generators.stores,
105
- ], docs);
106
- // don't log anything if its quiet
107
- if (config.logLevel === common_1.LogLevel.Quiet) {
123
+ catch (e) {
124
+ error = e;
125
+ }
126
+ /// Summary
127
+ // count the number of unchanged
128
+ const unchanged = artifactStats.total.length -
129
+ artifactStats.changed.length -
130
+ artifactStats.new.length -
131
+ artifactStats.deleted.length;
132
+ // If triggered from the plugin, we show logs ONLY if there are changes.
133
+ const printMessage = !config.plugin || unchanged !== artifactStats.total.length;
134
+ if (!printMessage || config.logLevel === common_1.LogLevel.Quiet) {
135
+ if (error) {
136
+ throw error;
137
+ }
138
+ return;
108
139
  }
109
- else if (versionChanged) {
140
+ if (!config.plugin) {
141
+ console.log('๐ŸŽฉ Generating runtime...');
142
+ }
143
+ if (error) {
144
+ throw error;
145
+ }
146
+ // if we detected a version change, we're nuking everything so don't bother with a summary
147
+ if (newTimestamp) {
110
148
  console.log('๐Ÿ’ฃ Detected new version of Houdini. Regenerating all documents...');
111
149
  console.log('๐ŸŽ‰ Welcome to HOUDINI_VERSION!');
112
150
  // if the user is coming from a version pre-15, point them to the migration guide
113
151
  const major = parseInt(previousVersion.split('.')[1]);
114
- if (major < 15) {
115
- console.log(`โ“ For a description of what's changed, visit this guide: https://www.houdinigraphql.com/guides/migrating-to-0.15.0
116
- โ“ Don't forget to update your sourceGlob config value if you want to define documents in external files.`);
152
+ if (major < 16) {
153
+ console.log(`โ“ For a description of what's changed, visit this guide: http://docs-next-kohl.vercel.app/guides/release-notes`);
117
154
  }
118
155
  }
156
+ // print a line showing that the process is finished (wo document)
157
+ else if (artifactStats.total.length === 0) {
158
+ console.log(`๐Ÿ’ก No operation found. If that's unexpected, please check your config.`);
159
+ }
160
+ // print summaries of the changes
119
161
  else if ([common_1.LogLevel.Summary, common_1.LogLevel.ShortSummary].includes(config.logLevel)) {
120
- // count the number of unchanged
121
- const unchanged = artifactStats.total.length -
122
- artifactStats.changed.length -
123
- artifactStats.new.length -
124
- artifactStats.deleted.length;
125
162
  // if we have any unchanged artifacts
126
- if (unchanged > 0) {
163
+ if (unchanged > 0 && printMessage && !config.plugin) {
127
164
  console.log(`๐Ÿ“ƒ Unchanged: ${unchanged}`);
128
165
  }
129
- if (artifactStats.changed.length > 0) {
130
- console.log(`โœ๏ธ Changed: ${artifactStats.changed.length}`);
131
- if (config.logLevel === common_1.LogLevel.Summary) {
132
- logFirst5(artifactStats.changed);
133
- }
134
- }
135
- if (artifactStats.new.length > 0) {
136
- console.log(`โœจ New: ${artifactStats.new.length}`);
137
- if (config.logLevel === common_1.LogLevel.Summary) {
138
- logFirst5(artifactStats.new);
139
- }
140
- }
141
- if (artifactStats.deleted.length > 0) {
142
- console.log(`๐Ÿงน Deleted: ${artifactStats.deleted.length}`);
143
- if (config.logLevel === common_1.LogLevel.Summary) {
144
- logFirst5(artifactStats.deleted);
145
- }
146
- }
166
+ logStyled('CREATED', artifactStats.new, config.logLevel, config.plugin);
167
+ logStyled('UPDATED', artifactStats.changed, config.logLevel, config.plugin);
168
+ logStyled('DELETED', artifactStats.deleted, config.logLevel, config.plugin);
147
169
  }
170
+ // print the status of every file
148
171
  else if (config.logLevel === common_1.LogLevel.Full) {
149
172
  for (const artifact of artifactStats.total) {
150
173
  // figure out the emoji to use
151
174
  let emoji = '๐Ÿ“ƒ';
152
175
  if (artifactStats.changed.includes(artifact)) {
153
- emoji = 'โœ๏ธ ';
176
+ emoji = 'โœ๏ธ';
154
177
  }
155
178
  else if (artifactStats.new.includes(artifact)) {
156
179
  emoji = 'โœจ';
@@ -166,52 +189,79 @@ async function runPipeline(config, docs) {
166
189
  exports.runPipeline = runPipeline;
167
190
  async function collectDocuments(config) {
168
191
  // the first step we have to do is grab a list of every file in the source tree
169
- const sourceFiles = await (0, util_1.promisify)(glob_1.default)(config.sourceGlob);
192
+ let sourceFiles = await (0, util_1.promisify)(glob_1.default)(config.include);
193
+ if (config.exclude) {
194
+ sourceFiles = sourceFiles.filter((filepath) => !(0, minimatch_1.default)(filepath, config.exclude));
195
+ }
170
196
  // the list of documents we found
171
197
  const documents = [];
172
198
  // wait for every file to be processed
173
199
  await Promise.all(sourceFiles.map(async (filepath) => {
174
200
  // read the file
175
- const contents = await promises_1.default.readFile(filepath, 'utf-8');
201
+ const contents = await (0, common_1.readFile)(filepath);
202
+ if (!contents) {
203
+ return;
204
+ }
176
205
  // if the file ends with .svelte, we need to look for graphql template tags
177
206
  if (filepath.endsWith('.svelte')) {
178
- documents.push(...(await findGraphQLTemplates(filepath, contents)));
207
+ documents.push(...(await processSvelteFile(filepath, contents)));
179
208
  }
180
- // otherwise just treat the file as a graphql file (the whole file contents constitute a graphql file)
181
- else {
209
+ else if (filepath.endsWith('.graphql') || filepath.endsWith('.gql')) {
182
210
  documents.push({
183
211
  filepath,
184
212
  document: contents,
185
213
  });
186
214
  }
215
+ // otherwise just treat the file as a javascript file
216
+ else {
217
+ documents.push(...(await processJSFile(config, filepath, contents)));
218
+ }
187
219
  }));
188
220
  return await Promise.all(documents.map(async ({ document, filepath }) => {
189
221
  try {
190
222
  return await processGraphQLDocument(config, filepath, document);
191
223
  }
192
224
  catch (e) {
193
- throw {
194
- ...e,
195
- filepath,
196
- };
225
+ throw new common_1.HoudiniError({ filepath, message: e.message });
197
226
  }
198
227
  }));
199
228
  }
200
- async function findGraphQLTemplates(filepath, contents) {
229
+ async function processJSFile(config, filepath, contents) {
230
+ const documents = [];
231
+ // parse the contents as js
232
+ let program;
233
+ try {
234
+ program = (await (0, common_1.parseJS)(contents)).script;
235
+ }
236
+ catch (e) {
237
+ // add the filepath to the error message
238
+ throw new common_1.HoudiniError({ filepath, message: e.message });
239
+ }
240
+ // look for a graphql template tag
241
+ await (0, common_1.walkGraphQLTags)(config, program, {
242
+ tag(tag) {
243
+ documents.push({ document: tag.tagContent, filepath });
244
+ },
245
+ });
246
+ // we found every document in the file
247
+ return documents;
248
+ }
249
+ async function processSvelteFile(filepath, contents) {
201
250
  const documents = [];
202
251
  let parsedFile;
203
252
  try {
204
- parsedFile = await (0, common_1.parseFile)(contents);
253
+ parsedFile = await (0, common_1.parseSvelte)(contents);
205
254
  }
206
255
  catch (e) {
207
256
  const err = e;
208
257
  // add the filepath to the error message
209
- throw { message: `Encountered error parsing ${filepath}`, description: err.message };
258
+ throw new common_1.HoudiniError({
259
+ message: `Encountered error parsing ${filepath}`,
260
+ description: err.message,
261
+ });
210
262
  }
211
263
  // we need to look for multiple script tags to support sveltekit
212
- const scripts = [parsedFile.instance, parsedFile.module]
213
- .map((script) => (script ? script.content : null))
214
- .filter(Boolean);
264
+ const scripts = [parsedFile];
215
265
  await Promise.all(scripts.map(async (jsContent) => {
216
266
  // @ts-ignore
217
267
  // look for any template tag literals in the script body
@@ -240,13 +290,19 @@ async function processGraphQLDocument(config, filepath, document) {
240
290
  const fragments = parsedDoc.definitions.filter(({ kind }) => kind === graphql.Kind.FRAGMENT_DEFINITION);
241
291
  // if there is more than one operation, throw an error
242
292
  if (operations.length > 1) {
243
- throw { filepath, message: 'Operation documents can only have one operation' };
293
+ throw new common_1.HoudiniError({
294
+ filepath,
295
+ message: 'Operation documents can only have one operation',
296
+ });
244
297
  }
245
298
  // we are looking at a fragment document
246
299
  else {
247
300
  // if there is more than one fragment, throw an error
248
301
  if (fragments.length > 1) {
249
- throw { filepath, message: 'Fragment documents can only have one fragment' };
302
+ throw new common_1.HoudiniError({
303
+ filepath,
304
+ message: 'Fragment documents can only have one fragment',
305
+ });
250
306
  }
251
307
  }
252
308
  // figure out the document kind
@@ -280,13 +336,51 @@ async function processGraphQLDocument(config, filepath, document) {
280
336
  originalString: document,
281
337
  };
282
338
  }
283
- function logFirst5(values) {
284
- // grab the first 5 changed documents
285
- for (const artifact of values.slice(0, 5)) {
286
- console.log(` ${artifact}`);
287
- }
288
- // if there are more than 5 just tell them how many
289
- if (values.length > 5) {
290
- console.log(` ... ${values.length - 5} more`);
339
+ function logStyled(kind, stat, logLevel, plugin) {
340
+ if (stat.length > 0) {
341
+ // Let's prepare the one liner in the plugin mode, of a bit more in other lol level.
342
+ const msg = [];
343
+ // in plugin mode, it will be very short, let's put a hat first.
344
+ if (plugin) {
345
+ msg.push(`๐ŸŽฉ `);
346
+ }
347
+ if (kind === 'CREATED') {
348
+ msg.push(`โœจ `);
349
+ if (!plugin) {
350
+ msg.push(`New: ${stat.length}`);
351
+ }
352
+ }
353
+ else if (kind === 'UPDATED') {
354
+ msg.push(`โœ๏ธ `);
355
+ if (!plugin) {
356
+ msg.push(`Changed: ${stat.length}`);
357
+ }
358
+ }
359
+ else if (kind === 'DELETED') {
360
+ msg.push(`๐Ÿงน `);
361
+ if (!plugin) {
362
+ msg.push(`Deleted: ${stat.length}`);
363
+ }
364
+ }
365
+ // let's do a summary for x elements
366
+ const nbToDisplay = 5;
367
+ // format for plugin
368
+ if (plugin) {
369
+ msg.push(`${stat.slice(0, nbToDisplay).join(', ')}`);
370
+ if (stat.length > 5) {
371
+ msg.push(`, ... ${stat.length - nbToDisplay} more`);
372
+ }
373
+ }
374
+ console.log(msg.join(''));
375
+ // Format for not plugin & Summary mode
376
+ if (!plugin && logLevel === common_1.LogLevel.Summary) {
377
+ for (const artifact of stat.slice(0, nbToDisplay)) {
378
+ console.log(` ${artifact}`);
379
+ }
380
+ // if there are more than 5 just tell them how many
381
+ if (stat.length > nbToDisplay) {
382
+ console.log(` ... ${stat.length - nbToDisplay} more`);
383
+ }
384
+ }
291
385
  }
292
386
  }
@@ -23,7 +23,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- // external imports
27
26
  const graphql = __importStar(require("graphql"));
28
27
  // we need to generate a static key that we can use to index this field in the cache.
29
28
  // this needs to be a unique hash driven by the field's attribute and arguments
@@ -34,9 +33,7 @@ function fieldKey(config, field) {
34
33
  const attributeName = field.alias?.value || field.name.value;
35
34
  // field might not have a location so print and re-parse before we look at serialized values
36
35
  const printed = graphql.print(field);
37
- const secondParse = graphql.parse(`{${printed}}`)
38
- .definitions[0].selectionSet
39
- .selections[0];
36
+ const secondParse = graphql.parse(`{${printed}}`).definitions[0].selectionSet.selections[0];
40
37
  // if the field is paginated, we need to strip away any args
41
38
  const paginated = !!field.directives?.find((directive) => directive.name.value === config.paginateDirective);
42
39
  const paginationArgs = ['first', 'after', 'last', 'before', 'limit', 'offset'];
@@ -1,5 +1,5 @@
1
- import { CollectedGraphQLDocument } from '../../types';
2
1
  import { Config } from '../../../common';
2
+ import { CollectedGraphQLDocument } from '../../types';
3
3
  export default function artifactGenerator(stats: {
4
4
  total: string[];
5
5
  new: string[];