houdini 0.16.1 → 0.16.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 (51) hide show
  1. package/CHANGELOG.md +27 -9
  2. package/build/cmd/generators/typescript/index.js +0 -2
  3. package/build/cmd/init.js +70 -18
  4. package/build/cmd/transforms/schema.js +12 -3
  5. package/build/cmd/utils/flattenSelections.d.ts +1 -2
  6. package/build/cmd/utils/flattenSelections.js +9 -6
  7. package/build/cmd/utils/introspection.d.ts +1 -2
  8. package/build/cmd/utils/introspection.js +3 -4
  9. package/build/cmd.js +135 -40
  10. package/build/common/config.d.ts +2 -0
  11. package/build/common/config.js +33 -6
  12. package/build/common/fs.d.ts +1 -0
  13. package/build/common/fs.js +9 -1
  14. package/build/preprocess-cjs/index.js +97 -40
  15. package/build/preprocess-esm/index.js +97 -40
  16. package/build/runtime/lib/config.d.ts +1 -1
  17. package/build/runtime/lib/network.js +5 -0
  18. package/build/runtime-cjs/lib/config.d.ts +1 -1
  19. package/build/runtime-cjs/lib/network.js +5 -0
  20. package/build/runtime-cjs/meta.json +1 -1
  21. package/build/runtime-esm/lib/config.d.ts +1 -1
  22. package/build/runtime-esm/lib/network.js +5 -0
  23. package/build/runtime-esm/meta.json +1 -1
  24. package/build/vite/fsPatch.js +7 -4
  25. package/build/vite/schema.js +10 -6
  26. package/build/vite/transforms/kit/index.js +5 -1
  27. package/build/vite/transforms/kit/session.js +50 -30
  28. package/build/vite-cjs/index.js +135 -61
  29. package/build/vite-esm/index.js +135 -61
  30. package/package.json +1 -1
  31. package/site/src/routes/api/config.svx +1 -1
  32. package/site/src/routes/api/fragments.svx +20 -0
  33. package/site/src/routes/index.svelte +7 -7
  34. package/site/src/routes/intro/fetching-data.svx +5 -3
  35. package/site/src/routes/intro/fragments.svx +6 -4
  36. package/site/src/routes/intro/mutations.svx +14 -4
  37. package/site/src/routes/intro/pagination.svx +3 -3
  38. package/src/cmd/generators/typescript/index.ts +0 -2
  39. package/src/cmd/init.ts +69 -18
  40. package/src/cmd/transforms/schema.ts +27 -8
  41. package/src/cmd/utils/flattenSelections.ts +13 -8
  42. package/src/cmd/utils/introspection.ts +4 -5
  43. package/src/common/config.ts +44 -6
  44. package/src/common/fs.ts +9 -0
  45. package/src/runtime/lib/config.ts +1 -1
  46. package/src/runtime/lib/network.ts +5 -0
  47. package/src/vite/fsPatch.ts +8 -6
  48. package/src/vite/schema.ts +12 -6
  49. package/src/vite/transforms/kit/index.ts +6 -1
  50. package/src/vite/transforms/kit/load.ts +0 -1
  51. package/src/vite/transforms/kit/session.ts +79 -41
package/CHANGELOG.md CHANGED
@@ -1,8 +1,24 @@
1
1
  # houdini
2
2
 
3
+ ## 0.16.2
4
+
5
+ ### ✨ Features
6
+
7
+ - [#534](https://github.com/HoudiniGraphql/houdini/pull/534) [`599fc3c`](https://github.com/HoudiniGraphql/houdini/commit/599fc3c9dc7843c40ab25b4c4763e1b3ed9df6c7) Thanks [@fehnomenal](https://github.com/fehnomenal)! - Add ability to control masking for a specific fragment
8
+
9
+ ### 🐛 Fixes
10
+
11
+ - [#540](https://github.com/HoudiniGraphql/houdini/pull/540) [`8addece`](https://github.com/HoudiniGraphql/houdini/commit/8addecef1063dfe7d48f539d1c9f6b72949d7fd2) Thanks [@jycouet](https://github.com/jycouet)! - Warn users when endpoint is not present in dev instead of crashing
12
+
13
+ * [#542](https://github.com/HoudiniGraphql/houdini/pull/542) [`3697e33`](https://github.com/HoudiniGraphql/houdini/commit/3697e33ec644f87f13878b74413b507843d90325) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - Fix bug when loading queries in a layout file
14
+
15
+ - [#539](https://github.com/HoudiniGraphql/houdini/pull/539) [`a7d4c2e`](https://github.com/HoudiniGraphql/houdini/commit/a7d4c2e9f650b86f8e19833079c286a64f807d2a) Thanks [@jycouet](https://github.com/jycouet)! - mono repo support
16
+
17
+ - [#537](https://github.com/HoudiniGraphql/houdini/pull/537) [`191c775`](https://github.com/HoudiniGraphql/houdini/commit/191c7750a33b11cdbc8f5e7b9719641d5b0a21c5) Thanks [@jycouet](https://github.com/jycouet)! - init cmd, vite.config.ts generated file
18
+
3
19
  ## 0.16.1
4
20
 
5
- ### Patch Changes
21
+ ### 🐛 Fixes
6
22
 
7
23
  - [#527](https://github.com/HoudiniGraphql/houdini/pull/527) [`9b87678`](https://github.com/HoudiniGraphql/houdini/commit/9b876789140978c0726ed9a708677c7c75f3e19b) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - Update init command to work with latest file template
8
24
 
@@ -32,24 +48,26 @@
32
48
 
33
49
  * [#449](https://github.com/HoudiniGraphql/houdini/pull/449) [`59257d1`](https://github.com/HoudiniGraphql/houdini/commit/59257d1dffa6c1d9d250ba0964c6f1f0c35da048) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - You can now define the prefix of your global stores with globalStorePrefix param in the config.
34
50
 
35
- - [#485](https://github.com/HoudiniGraphql/houdini/pull/485) [`c21942c`](https://github.com/HoudiniGraphql/houdini/commit/c21942c4a364dbaca4008dc0ad8263fdc940da84) Thanks [@jycouet](https://github.com/jycouet)! - fix peerDependencies of houdini, graphql needs to be <16
36
-
37
- * [#490](https://github.com/HoudiniGraphql/houdini/pull/490) [`71caba7`](https://github.com/HoudiniGraphql/houdini/commit/71caba7c6b23e73754934fd604030f3cd1a9b74b) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - fix generated types for optimistic responses
38
-
39
- - [#487](https://github.com/HoudiniGraphql/houdini/pull/487) [`0544a28`](https://github.com/HoudiniGraphql/houdini/commit/0544a2846125673f2f0e67cb02135554458edfb0) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - Fix issues when rendering kit applications with framework set to "svelte"
40
-
41
51
  * [#508](https://github.com/HoudiniGraphql/houdini/pull/508) [`60ecb33`](https://github.com/HoudiniGraphql/houdini/commit/60ecb333a1396f9aa7244eac2f38741a58e7281f) Thanks [@fehnomenal](https://github.com/fehnomenal)! - added support for sessions
42
52
 
43
53
  * [#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
44
54
 
45
55
  * [#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
46
56
 
47
- - [#523](https://github.com/HoudiniGraphql/houdini/pull/523) [`2c5174c`](https://github.com/HoudiniGraphql/houdini/commit/2c5174c248bf2ae5ee3a8d3a7e910213e859ae2a) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - fix circular import with HoudiniClient
48
-
49
57
  - [#494](https://github.com/HoudiniGraphql/houdini/pull/494) [`5573cfa`](https://github.com/HoudiniGraphql/houdini/commit/5573cfa184d2da322030695044997f5fbf6542bd) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - add onError hook
50
58
 
51
59
  - [#494](https://github.com/HoudiniGraphql/houdini/pull/494) [`5573cfa`](https://github.com/HoudiniGraphql/houdini/commit/5573cfa184d2da322030695044997f5fbf6542bd) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - add `quietQueryError` config value to suppress all query errors
52
60
 
61
+ ### 🐛 Fixes
62
+
63
+ - [#485](https://github.com/HoudiniGraphql/houdini/pull/485) [`c21942c`](https://github.com/HoudiniGraphql/houdini/commit/c21942c4a364dbaca4008dc0ad8263fdc940da84) Thanks [@jycouet](https://github.com/jycouet)! - fix peerDependencies of houdini, graphql needs to be <16
64
+
65
+ - [#523](https://github.com/HoudiniGraphql/houdini/pull/523) [`2c5174c`](https://github.com/HoudiniGraphql/houdini/commit/2c5174c248bf2ae5ee3a8d3a7e910213e859ae2a) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - fix circular import with HoudiniClient
66
+
67
+ - [#490](https://github.com/HoudiniGraphql/houdini/pull/490) [`71caba7`](https://github.com/HoudiniGraphql/houdini/commit/71caba7c6b23e73754934fd604030f3cd1a9b74b) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - fix generated types for optimistic responses
68
+
69
+ - [#487](https://github.com/HoudiniGraphql/houdini/pull/487) [`0544a28`](https://github.com/HoudiniGraphql/houdini/commit/0544a2846125673f2f0e67cb02135554458edfb0) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - Fix issues when rendering kit applications with framework set to "svelte"
70
+
53
71
  ## 0.15.9
54
72
 
55
73
  ### Patch Changes
@@ -71,8 +71,6 @@ async function typescriptGenerator(config, docs) {
71
71
  config,
72
72
  filepath: filename,
73
73
  selections: definition.selectionSet.selections,
74
- // only globally include internal fragment values if masking is disabled
75
- includeFragments: config.disableMasking,
76
74
  fragmentDefinitions,
77
75
  });
78
76
  if (definition?.kind === 'OperationDefinition') {
package/build/cmd/init.js CHANGED
@@ -276,7 +276,7 @@ async function tjsConfig(targetPath, framework) {
276
276
  return false;
277
277
  }
278
278
  async function updateViteConfig(targetPath, framework, typescript) {
279
- const viteConfigPath = path_1.default.join(targetPath, 'vite.config' + typescript ? '.ts' : '.js');
279
+ const viteConfigPath = path_1.default.join(targetPath, `vite.config${typescript ? '.ts' : '.js'}`);
280
280
  const oldViteConfig1 = `import { sveltekit } from '@sveltejs/kit/vite';
281
281
 
282
282
  /** @type {import('vite').UserConfig} */
@@ -304,6 +304,16 @@ const config = {
304
304
  plugins: [houdini(), sveltekit()],
305
305
  }
306
306
 
307
+ export default config;
308
+ `;
309
+ const viteConfigKitTs = `import { sveltekit } from '@sveltejs/kit/vite';
310
+ import houdini from 'houdini/vite';
311
+ import type { UserConfig } from "vite";
312
+
313
+ const config: UserConfig = {
314
+ plugins: [houdini(), sveltekit()],
315
+ }
316
+
307
317
  export default config;
308
318
  `;
309
319
  const viteConfigSvelte = `import { svelte } from '@sveltejs/vite-plugin-svelte';
@@ -316,34 +326,76 @@ const config = {
316
326
 
317
327
  export default config;
318
328
  `;
329
+ const viteConfigSvelteTs = `import { svelte } from '@sveltejs/vite-plugin-svelte';
330
+ import houdini from 'houdini/vite';
331
+ import type { UserConfig } from "vite";
332
+
333
+ const config: UserConfig = {
334
+ plugins: [houdini(), svelte()],
335
+ }
336
+
337
+ export default config;
338
+ `;
339
+ let content = 'NOTHING!';
340
+ if (framework === 'kit' && typescript) {
341
+ content = viteConfigKitTs;
342
+ }
343
+ else if (framework === 'kit' && !typescript) {
344
+ content = viteConfigKit;
345
+ }
346
+ else if (framework === 'svelte' && typescript) {
347
+ content = viteConfigSvelteTs;
348
+ }
349
+ else if (framework === 'svelte' && !typescript) {
350
+ content = viteConfigSvelte;
351
+ }
352
+ else {
353
+ throw new Error('Unknown updateViteConfig()');
354
+ }
319
355
  // write the vite config file
320
356
  await updateFile({
321
357
  projectPath: targetPath,
322
358
  filepath: viteConfigPath,
323
- content: framework === 'kit' ? viteConfigKit : viteConfigSvelte,
359
+ content,
324
360
  old: [oldViteConfig1, oldViteConfig2],
325
361
  });
362
+ if (typescript) {
363
+ await updateFile({
364
+ projectPath: targetPath,
365
+ filepath: viteConfigPath,
366
+ content: framework === 'kit' ? viteConfigKitTs : viteConfigSvelteTs,
367
+ old: [oldViteConfig1, oldViteConfig2],
368
+ });
369
+ }
370
+ else {
371
+ await updateFile({
372
+ projectPath: targetPath,
373
+ filepath: viteConfigPath,
374
+ content: framework === 'kit' ? viteConfigKit : viteConfigSvelte,
375
+ old: [oldViteConfig1, oldViteConfig2],
376
+ });
377
+ }
326
378
  }
327
379
  async function updateSvelteConfig(targetPath) {
328
380
  const svelteConfigPath = path_1.default.join(targetPath, 'svelte.config.js');
329
381
  const newContent = `import adapter from '@sveltejs/adapter-auto';
330
- import preprocess from 'svelte-preprocess';
331
-
332
- /** @type {import('@sveltejs/kit').Config} */
333
- const config = {
334
- // Consult https://github.com/sveltejs/svelte-preprocess
335
- // for more information about preprocessors
336
- preprocess: preprocess(),
337
-
338
- kit: {
339
- adapter: adapter(),
340
- alias: {
341
- $houdini: './$houdini',
342
- }
382
+ import preprocess from 'svelte-preprocess';
383
+
384
+ /** @type {import('@sveltejs/kit').Config} */
385
+ const config = {
386
+ // Consult https://github.com/sveltejs/svelte-preprocess
387
+ // for more information about preprocessors
388
+ preprocess: preprocess(),
389
+
390
+ kit: {
391
+ adapter: adapter(),
392
+ alias: {
393
+ $houdini: './$houdini',
343
394
  }
344
- };
345
-
346
- export default config;
395
+ }
396
+ };
397
+
398
+ export default config;
347
399
  `;
348
400
  const oldSvelteConfig1 = `import adapter from '@sveltejs/adapter-auto';
349
401
  import preprocess from 'svelte-preprocess';
@@ -88,9 +88,18 @@ directive @${config.argumentsDirective} on FRAGMENT_DEFINITION
88
88
  directive @${config.cacheDirective}(${config.cachePolicyArg}: CachePolicy, ${config.cachePartialArg}: Boolean) on QUERY
89
89
 
90
90
  """
91
- @${config.houdiniDirective} is used to configure houdini's internal behavior such as opting-in an automatic load
92
- """
93
- directive @${config.houdiniDirective}(load: Boolean = true) on QUERY
91
+ @${config.houdiniDirective} is used to configure houdini's internal behavior
92
+ """
93
+ directive @${config.houdiniDirective}(
94
+ """
95
+ Opt-in to an automatic load function (only valid when used at queries)
96
+ """
97
+ load: Boolean! = true
98
+ """
99
+ Mask fragment fields (only valid when used at a fragment spread)
100
+ """
101
+ mask: Boolean! = ${config.disableMasking ? 'false' : 'true'}
102
+ ) on QUERY | FRAGMENT_SPREAD
94
103
  `;
95
104
  // if the config does not have the cache directive, then we need to add it
96
105
  let currentSchema = graphql.printSchema(config.schema);
@@ -1,10 +1,9 @@
1
1
  import * as graphql from 'graphql';
2
2
  import { Config } from '../../common';
3
- export declare function flattenSelections({ config, filepath, selections, includeFragments, fragmentDefinitions, }: {
3
+ export declare function flattenSelections({ config, filepath, selections, fragmentDefinitions, }: {
4
4
  config: Config;
5
5
  filepath: string;
6
6
  selections: readonly graphql.SelectionNode[];
7
- includeFragments: boolean;
8
7
  fragmentDefinitions: {
9
8
  [name: string]: graphql.FragmentDefinitionNode;
10
9
  };
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.flattenSelections = void 0;
4
4
  const common_1 = require("../../common");
5
- function flattenSelections({ config, filepath, selections, includeFragments, fragmentDefinitions, }) {
5
+ function flattenSelections({ config, filepath, selections, fragmentDefinitions, }) {
6
6
  // collect all of the fields together
7
7
  const fields = new FieldCollection({
8
8
  config,
9
9
  filepath,
10
10
  selections,
11
- includeFragments,
12
11
  fragmentDefinitions,
13
12
  });
14
13
  // convert the flat fields into a selection set
@@ -17,9 +16,7 @@ function flattenSelections({ config, filepath, selections, includeFragments, fra
17
16
  exports.flattenSelections = flattenSelections;
18
17
  class FieldCollection {
19
18
  constructor(args) {
20
- this.includeFragments = false;
21
19
  this.config = args.config;
22
- this.includeFragments = args.includeFragments;
23
20
  this.fragmentDefinitions = args.fragmentDefinitions;
24
21
  this.fields = {};
25
22
  this.inlineFragments = {};
@@ -80,8 +77,15 @@ class FieldCollection {
80
77
  // the application of the fragment has been validated already so track it
81
78
  // so we can recreate
82
79
  this.fragmentSpreads[selection.name.value] = selection;
80
+ // find whether to include fragment fields
81
+ const houdiniDirective = selection.directives?.find(({ name }) => name.value === this.config.houdiniDirective);
82
+ const maskArgument = houdiniDirective?.arguments?.find(({ name }) => name.value === 'mask');
83
+ let includeFragments = this.config.disableMasking;
84
+ if (maskArgument?.value.kind === 'BooleanValue') {
85
+ includeFragments = !maskArgument.value.value;
86
+ }
83
87
  // we're finished if we're not supposed to include fragments in the selection
84
- if (!this.includeFragments) {
88
+ if (!includeFragments) {
85
89
  return;
86
90
  }
87
91
  const definition = this.fragmentDefinitions[selection.name.value];
@@ -113,7 +117,6 @@ class FieldCollection {
113
117
  empty() {
114
118
  return new FieldCollection({
115
119
  config: this.config,
116
- includeFragments: this.includeFragments,
117
120
  fragmentDefinitions: this.fragmentDefinitions,
118
121
  selections: [],
119
122
  filepath: this.filepath,
@@ -1,2 +1 @@
1
- import * as graphql from 'graphql';
2
- export declare function pullSchema(url: string, schemaPath: string, headers?: Record<string, string>): Promise<graphql.GraphQLSchema>;
1
+ export declare function pullSchema(url: string, schemaPath: string, headers?: Record<string, string>): Promise<boolean>;
@@ -52,12 +52,11 @@ async function pullSchema(url, schemaPath, headers) {
52
52
  else {
53
53
  await (0, fs_1.writeFile)(schemaPath, JSON.stringify(jsonSchema));
54
54
  }
55
- // return the schema for usage in --pull-schema
56
- return schema;
55
+ return true;
57
56
  }
58
57
  catch (e) {
59
- console.log(`❌ Encountered error when pulling your latest schema: ` + e.message);
60
- process.exit(0);
58
+ console.warn(`⚠️ Couldn't pull your latest schema: ` + e.message);
61
59
  }
60
+ return false;
62
61
  }
63
62
  exports.pullSchema = pullSchema;
package/build/cmd.js CHANGED
@@ -9235,13 +9235,12 @@ function exportDefaultFrom(where, as) {
9235
9235
  Object.defineProperty(exports, "${as}", { enumerable: true, get: function () { return __importDefault(${as}).default; } });`;
9236
9236
  }
9237
9237
 
9238
- function flattenSelections({ config, filepath, selections, includeFragments, fragmentDefinitions, }) {
9238
+ function flattenSelections({ config, filepath, selections, fragmentDefinitions, }) {
9239
9239
  // collect all of the fields together
9240
9240
  const fields = new FieldCollection({
9241
9241
  config,
9242
9242
  filepath,
9243
9243
  selections,
9244
- includeFragments,
9245
9244
  fragmentDefinitions,
9246
9245
  });
9247
9246
  // convert the flat fields into a selection set
@@ -9249,9 +9248,7 @@ function flattenSelections({ config, filepath, selections, includeFragments, fra
9249
9248
  }
9250
9249
  class FieldCollection {
9251
9250
  constructor(args) {
9252
- this.includeFragments = false;
9253
9251
  this.config = args.config;
9254
- this.includeFragments = args.includeFragments;
9255
9252
  this.fragmentDefinitions = args.fragmentDefinitions;
9256
9253
  this.fields = {};
9257
9254
  this.inlineFragments = {};
@@ -9312,8 +9309,15 @@ class FieldCollection {
9312
9309
  // the application of the fragment has been validated already so track it
9313
9310
  // so we can recreate
9314
9311
  this.fragmentSpreads[selection.name.value] = selection;
9312
+ // find whether to include fragment fields
9313
+ const houdiniDirective = selection.directives?.find(({ name }) => name.value === this.config.houdiniDirective);
9314
+ const maskArgument = houdiniDirective?.arguments?.find(({ name }) => name.value === 'mask');
9315
+ let includeFragments = this.config.disableMasking;
9316
+ if (maskArgument?.value.kind === 'BooleanValue') {
9317
+ includeFragments = !maskArgument.value.value;
9318
+ }
9315
9319
  // we're finished if we're not supposed to include fragments in the selection
9316
- if (!this.includeFragments) {
9320
+ if (!includeFragments) {
9317
9321
  return;
9318
9322
  }
9319
9323
  const definition = this.fragmentDefinitions[selection.name.value];
@@ -9345,7 +9349,6 @@ class FieldCollection {
9345
9349
  empty() {
9346
9350
  return new FieldCollection({
9347
9351
  config: this.config,
9348
- includeFragments: this.includeFragments,
9349
9352
  fragmentDefinitions: this.fragmentDefinitions,
9350
9353
  selections: [],
9351
9354
  filepath: this.filepath,
@@ -117321,6 +117324,13 @@ async function stat(filepath) {
117321
117324
  }
117322
117325
  return lib$2.exports.fs.statSync(filepath);
117323
117326
  }
117327
+ function existsSync(dirPath) {
117328
+ // no mock in production
117329
+ if (process.env.NODE_ENV !== 'test') {
117330
+ return lib$3.existsSync(dirPath);
117331
+ }
117332
+ return lib$2.exports.fs.existsSync(dirPath);
117333
+ }
117324
117334
  async function readdir(filepath) {
117325
117335
  // no mock in production
117326
117336
  if (process.env.NODE_ENV !== 'test') {
@@ -117362,13 +117372,12 @@ async function pullSchema$1(url, schemaPath, headers) {
117362
117372
  else {
117363
117373
  await writeFile(schemaPath, JSON.stringify(jsonSchema));
117364
117374
  }
117365
- // return the schema for usage in --pull-schema
117366
- return schema;
117375
+ return true;
117367
117376
  }
117368
117377
  catch (e) {
117369
- console.log(`❌ Encountered error when pulling your latest schema: ` + e.message);
117370
- process.exit(0);
117378
+ console.warn(`⚠️ Couldn't pull your latest schema: ` + e.message);
117371
117379
  }
117380
+ return false;
117372
117381
  }
117373
117382
 
117374
117383
  Promise.resolve();
@@ -154162,15 +154171,35 @@ ${hasDefault
154162
154171
  get typeRootFile() {
154163
154172
  return '$houdini.d.ts';
154164
154173
  }
154174
+ findNodeModulesHoudini(currentLocation) {
154175
+ const pathEndingBy = ['node_modules', 'houdini'];
154176
+ // Build the first possible location
154177
+ let locationFound = path$h.join(currentLocation, ...pathEndingBy);
154178
+ // previousLocation is nothing
154179
+ let previousLocation = '';
154180
+ const backFolder = [];
154181
+ // if previousLocation !== locationFound that mean that we can go upper
154182
+ // if the directory doesn't exist, let's go upper.
154183
+ while (previousLocation !== locationFound && !existsSync(locationFound)) {
154184
+ // save the previous path
154185
+ previousLocation = locationFound;
154186
+ // add a back folder
154187
+ backFolder.push('../');
154188
+ // set the new location
154189
+ locationFound = path$h.join(currentLocation, ...backFolder, ...pathEndingBy);
154190
+ }
154191
+ if (previousLocation === locationFound) {
154192
+ throw new Error('Could not find any node_modules/houdini folder');
154193
+ }
154194
+ return locationFound;
154195
+ }
154165
154196
  get runtimeSource() {
154166
154197
  // when running in the real world, scripts are nested in a sub directory of build, in tests they aren't nested
154167
154198
  // under /src so we need to figure out how far up to go to find the appropriately compiled runtime
154168
154199
  const relative = process.env.TEST
154169
154200
  ? path$h.join(currentDir, '../../')
154170
- : // TODO: it's very possible this breaks someones setup. the old version walked up from currentDir
154171
- // there isn't a consistent number of steps up anymore since the vite plugin and cmd live at different depths
154172
- // a better approach could be to start at current dir and walk up until we find a `houdini` dir
154173
- path$h.join(path$h.dirname(this.filepath), 'node_modules', 'houdini');
154201
+ : // start here and go to parent until we find the node_modules/houdini folder
154202
+ this.findNodeModulesHoudini(path$h.join(path$h.dirname(this.filepath)));
154174
154203
  // we want to copy the typescript source code for the templates and then compile the files according
154175
154204
  // to the requirements of the platform
154176
154205
  return path$h.resolve(relative, 'build', this.module === 'esm' ? 'runtime-esm' : 'runtime-cjs');
@@ -154441,6 +154470,10 @@ ${hasDefault
154441
154470
  return (this.resolveRelative(filename).replace(this.projectRoot, '').replace('.ts', '.js') ===
154442
154471
  path$h.sep + path$h.join('src', 'routes', '+layout.server.js'));
154443
154472
  }
154473
+ isRootLayoutScript(filename) {
154474
+ return (this.resolveRelative(filename).replace(this.projectRoot, '').replace('.ts', '.js') ===
154475
+ path$h.sep + path$h.join('src', 'routes', '+layout.js'));
154476
+ }
154444
154477
  isComponent(filename) {
154445
154478
  return (this.framework === 'svelte' ||
154446
154479
  (filename.endsWith('.svelte') &&
@@ -154651,6 +154684,7 @@ async function getConfig({ configFile, ...extraConfig } = {}) {
154651
154684
  });
154652
154685
  // look up the schema if we need to
154653
154686
  if (_config.schemaPath && !_config.schema) {
154687
+ let schemaOk = true;
154654
154688
  // we might have to pull the schema first
154655
154689
  if (_config.apiUrl) {
154656
154690
  // make sure we don't have a pattern pointing to multiple files and a remove URL
@@ -154661,11 +154695,13 @@ This will prevent your schema from being pulled (potentially resulting in errors
154661
154695
  // we might have to create the file
154662
154696
  else if (!(await readFile(_config.schemaPath))) {
154663
154697
  console.log('⌛ Pulling schema from api');
154664
- await pullSchema$1(_config.apiUrl, _config.schemaPath);
154698
+ schemaOk = await pullSchema$1(_config.apiUrl, _config.schemaPath);
154665
154699
  }
154666
154700
  }
154667
154701
  // the schema is safe to load
154668
- _config.schema = await loadSchemaFile(_config.schemaPath);
154702
+ if (schemaOk) {
154703
+ _config.schema = await loadSchemaFile(_config.schemaPath);
154704
+ }
154669
154705
  }
154670
154706
  }
154671
154707
  catch (e) {
@@ -157153,8 +157189,6 @@ async function typescriptGenerator(config, docs) {
157153
157189
  config,
157154
157190
  filepath: filename,
157155
157191
  selections: definition.selectionSet.selections,
157156
- // only globally include internal fragment values if masking is disabled
157157
- includeFragments: config.disableMasking,
157158
157192
  fragmentDefinitions,
157159
157193
  });
157160
157194
  if (definition?.kind === 'OperationDefinition') {
@@ -157996,9 +158030,18 @@ directive @${config.argumentsDirective} on FRAGMENT_DEFINITION
157996
158030
  directive @${config.cacheDirective}(${config.cachePolicyArg}: CachePolicy, ${config.cachePartialArg}: Boolean) on QUERY
157997
158031
 
157998
158032
  """
157999
- @${config.houdiniDirective} is used to configure houdini's internal behavior such as opting-in an automatic load
158033
+ @${config.houdiniDirective} is used to configure houdini's internal behavior
158000
158034
  """
158001
- directive @${config.houdiniDirective}(load: Boolean = true) on QUERY
158035
+ directive @${config.houdiniDirective}(
158036
+ """
158037
+ Opt-in to an automatic load function (only valid when used at queries)
158038
+ """
158039
+ load: Boolean! = true
158040
+ """
158041
+ Mask fragment fields (only valid when used at a fragment spread)
158042
+ """
158043
+ mask: Boolean! = ${config.disableMasking ? 'false' : 'true'}
158044
+ ) on QUERY | FRAGMENT_SPREAD
158002
158045
  `;
158003
158046
  // if the config does not have the cache directive, then we need to add it
158004
158047
  let currentSchema = graphql.printSchema(config.schema);
@@ -159283,7 +159326,7 @@ async function runPipeline(config, docs) {
159283
159326
  // if we detected a version change, we're nuking everything so don't bother with a summary
159284
159327
  if (newTimestamp) {
159285
159328
  console.log('💣 Detected new version of Houdini. Regenerating all documents...');
159286
- console.log('🎉 Welcome to 0.16.1!');
159329
+ console.log('🎉 Welcome to 0.16.2!');
159287
159330
  // if the user is coming from a version pre-15, point them to the migration guide
159288
159331
  const major = parseInt(previousVersion.split('.')[1]);
159289
159332
  if (major < 16) {
@@ -166030,7 +166073,7 @@ async function tjsConfig(targetPath, framework) {
166030
166073
  return false;
166031
166074
  }
166032
166075
  async function updateViteConfig(targetPath, framework, typescript) {
166033
- const viteConfigPath = path$h.join(targetPath, 'vite.config' + typescript ? '.ts' : '.js');
166076
+ const viteConfigPath = path$h.join(targetPath, `vite.config${typescript ? '.ts' : '.js'}`);
166034
166077
  const oldViteConfig1 = `import { sveltekit } from '@sveltejs/kit/vite';
166035
166078
 
166036
166079
  /** @type {import('vite').UserConfig} */
@@ -166058,6 +166101,16 @@ const config = {
166058
166101
  plugins: [houdini(), sveltekit()],
166059
166102
  }
166060
166103
 
166104
+ export default config;
166105
+ `;
166106
+ const viteConfigKitTs = `import { sveltekit } from '@sveltejs/kit/vite';
166107
+ import houdini from 'houdini/vite';
166108
+ import type { UserConfig } from "vite";
166109
+
166110
+ const config: UserConfig = {
166111
+ plugins: [houdini(), sveltekit()],
166112
+ }
166113
+
166061
166114
  export default config;
166062
166115
  `;
166063
166116
  const viteConfigSvelte = `import { svelte } from '@sveltejs/vite-plugin-svelte';
@@ -166070,34 +166123,76 @@ const config = {
166070
166123
 
166071
166124
  export default config;
166072
166125
  `;
166126
+ const viteConfigSvelteTs = `import { svelte } from '@sveltejs/vite-plugin-svelte';
166127
+ import houdini from 'houdini/vite';
166128
+ import type { UserConfig } from "vite";
166129
+
166130
+ const config: UserConfig = {
166131
+ plugins: [houdini(), svelte()],
166132
+ }
166133
+
166134
+ export default config;
166135
+ `;
166136
+ let content = 'NOTHING!';
166137
+ if (framework === 'kit' && typescript) {
166138
+ content = viteConfigKitTs;
166139
+ }
166140
+ else if (framework === 'kit' && !typescript) {
166141
+ content = viteConfigKit;
166142
+ }
166143
+ else if (framework === 'svelte' && typescript) {
166144
+ content = viteConfigSvelteTs;
166145
+ }
166146
+ else if (framework === 'svelte' && !typescript) {
166147
+ content = viteConfigSvelte;
166148
+ }
166149
+ else {
166150
+ throw new Error('Unknown updateViteConfig()');
166151
+ }
166073
166152
  // write the vite config file
166074
166153
  await updateFile({
166075
166154
  projectPath: targetPath,
166076
166155
  filepath: viteConfigPath,
166077
- content: framework === 'kit' ? viteConfigKit : viteConfigSvelte,
166156
+ content,
166078
166157
  old: [oldViteConfig1, oldViteConfig2],
166079
166158
  });
166159
+ if (typescript) {
166160
+ await updateFile({
166161
+ projectPath: targetPath,
166162
+ filepath: viteConfigPath,
166163
+ content: framework === 'kit' ? viteConfigKitTs : viteConfigSvelteTs,
166164
+ old: [oldViteConfig1, oldViteConfig2],
166165
+ });
166166
+ }
166167
+ else {
166168
+ await updateFile({
166169
+ projectPath: targetPath,
166170
+ filepath: viteConfigPath,
166171
+ content: framework === 'kit' ? viteConfigKit : viteConfigSvelte,
166172
+ old: [oldViteConfig1, oldViteConfig2],
166173
+ });
166174
+ }
166080
166175
  }
166081
166176
  async function updateSvelteConfig(targetPath) {
166082
166177
  const svelteConfigPath = path$h.join(targetPath, 'svelte.config.js');
166083
166178
  const newContent = `import adapter from '@sveltejs/adapter-auto';
166084
- import preprocess from 'svelte-preprocess';
166085
-
166086
- /** @type {import('@sveltejs/kit').Config} */
166087
- const config = {
166088
- // Consult https://github.com/sveltejs/svelte-preprocess
166089
- // for more information about preprocessors
166090
- preprocess: preprocess(),
166091
-
166092
- kit: {
166093
- adapter: adapter(),
166094
- alias: {
166095
- $houdini: './$houdini',
166096
- }
166179
+ import preprocess from 'svelte-preprocess';
166180
+
166181
+ /** @type {import('@sveltejs/kit').Config} */
166182
+ const config = {
166183
+ // Consult https://github.com/sveltejs/svelte-preprocess
166184
+ // for more information about preprocessors
166185
+ preprocess: preprocess(),
166186
+
166187
+ kit: {
166188
+ adapter: adapter(),
166189
+ alias: {
166190
+ $houdini: './$houdini',
166097
166191
  }
166098
- };
166099
-
166100
- export default config;
166192
+ }
166193
+ };
166194
+
166195
+ export default config;
166101
166196
  `;
166102
166197
  const oldSvelteConfig1 = `import adapter from '@sveltejs/adapter-auto';
166103
166198
  import preprocess from 'svelte-preprocess';
@@ -166174,7 +166269,7 @@ async function updatePackageJSON(targetPath) {
166174
166269
  // houdini & graphql should be a dev dependencies
166175
166270
  packageJSON.devDependencies = {
166176
166271
  ...packageJSON.devDependencies,
166177
- houdini: '^0.16.1',
166272
+ houdini: '^0.16.2',
166178
166273
  graphql: '^15.5.0',
166179
166274
  };
166180
166275
  await writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
@@ -56,6 +56,7 @@ export declare class Config {
56
56
  get typeRootDir(): string;
57
57
  get typeRouteDir(): string;
58
58
  get typeRootFile(): string;
59
+ private findNodeModulesHoudini;
59
60
  get runtimeSource(): string;
60
61
  artifactTypePath(document: graphql.DocumentNode): string;
61
62
  artifactPath(document: graphql.DocumentNode): string;
@@ -119,6 +120,7 @@ export declare class Config {
119
120
  isRouteScript(filename: string): boolean;
120
121
  isRootLayout(filename: string): boolean;
121
122
  isRootLayoutServer(filename: string): boolean;
123
+ isRootLayoutScript(filename: string): boolean;
122
124
  isComponent(filename: string): boolean;
123
125
  pageQueryPath(filename: string): string;
124
126
  resolveRelative(filename: string): string;