houdini 0.15.6 → 0.15.9

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 (147) hide show
  1. package/.prettierignore +1 -0
  2. package/CHANGELOG.md +20 -0
  3. package/build/cmd/generators/runtime/adapter.js +1 -1
  4. package/build/cmd/generators/stores/pagination.d.ts +1 -1
  5. package/build/cmd/generators/stores/pagination.js +4 -18
  6. package/build/cmd/generators/stores/query.js +1 -1
  7. package/build/cmd/init.js +1 -1
  8. package/build/cmd/transforms/paginate.js +1 -1
  9. package/build/cmd/validators/typeCheck.d.ts +2 -0
  10. package/build/cmd/validators/typeCheck.js +38 -22
  11. package/build/cmd.js +208 -64
  12. package/build/preprocess-cjs/index.js +3 -2
  13. package/build/preprocess-esm/index.js +3 -2
  14. package/build/runtime/adapter.d.ts +2 -2
  15. package/build/runtime/cache/cache.js +3 -2
  16. package/build/runtime/inline/fragment.d.ts +4 -2
  17. package/build/runtime/inline/query.d.ts +4 -2
  18. package/build/runtime/lib/config.d.ts +2 -2
  19. package/build/runtime/lib/pagination.d.ts +26 -18
  20. package/build/runtime/lib/pagination.js +119 -81
  21. package/build/runtime/lib/session.d.ts +9 -0
  22. package/build/runtime/lib/session.js +47 -0
  23. package/build/runtime/stores/fragment.d.ts +3 -4
  24. package/build/runtime/stores/fragment.js +56 -7
  25. package/build/runtime/stores/mutation.js +22 -13
  26. package/build/runtime/stores/query.d.ts +22 -5
  27. package/build/runtime/stores/query.js +73 -70
  28. package/build/runtime-cjs/adapter.d.ts +2 -2
  29. package/build/runtime-cjs/cache/cache.js +3 -2
  30. package/build/runtime-cjs/inline/fragment.d.ts +4 -2
  31. package/build/runtime-cjs/inline/query.d.ts +4 -2
  32. package/build/runtime-cjs/lib/config.d.ts +2 -2
  33. package/build/runtime-cjs/lib/pagination.d.ts +26 -18
  34. package/build/runtime-cjs/lib/pagination.js +119 -81
  35. package/build/runtime-cjs/lib/session.d.ts +9 -0
  36. package/build/runtime-cjs/lib/session.js +47 -0
  37. package/build/runtime-cjs/stores/fragment.d.ts +3 -4
  38. package/build/runtime-cjs/stores/fragment.js +56 -7
  39. package/build/runtime-cjs/stores/mutation.js +22 -13
  40. package/build/runtime-cjs/stores/query.d.ts +22 -5
  41. package/build/runtime-cjs/stores/query.js +73 -70
  42. package/build/runtime-esm/adapter.d.ts +2 -2
  43. package/build/runtime-esm/cache/cache.js +3 -2
  44. package/build/runtime-esm/inline/fragment.d.ts +4 -2
  45. package/build/runtime-esm/inline/query.d.ts +4 -2
  46. package/build/runtime-esm/lib/config.d.ts +2 -2
  47. package/build/runtime-esm/lib/pagination.d.ts +26 -18
  48. package/build/runtime-esm/lib/pagination.js +121 -84
  49. package/build/runtime-esm/lib/session.d.ts +9 -0
  50. package/build/runtime-esm/lib/session.js +42 -0
  51. package/build/runtime-esm/stores/fragment.d.ts +3 -4
  52. package/build/runtime-esm/stores/fragment.js +58 -9
  53. package/build/runtime-esm/stores/mutation.js +23 -14
  54. package/build/runtime-esm/stores/query.d.ts +22 -5
  55. package/build/runtime-esm/stores/query.js +74 -72
  56. package/package.json +3 -2
  57. package/site/.env.example +1 -0
  58. package/site/.eslintrc.cjs +20 -0
  59. package/site/.husky/pre-commit +4 -0
  60. package/site/.prettierrc +7 -0
  61. package/site/README.md +26 -0
  62. package/site/package.json +51 -0
  63. package/site/src/app.d.ts +21 -0
  64. package/site/src/app.html +25 -0
  65. package/site/src/components/APIShowcase.svelte +109 -0
  66. package/site/src/components/DeepDive.svelte +50 -0
  67. package/site/src/components/GraphQLExplained.svelte +50 -0
  68. package/site/src/components/HeaderWithMode.svelte +53 -0
  69. package/site/src/components/Icon.svelte +38 -0
  70. package/site/src/components/SEO.svelte +19 -0
  71. package/site/src/components/Transformation.svelte +25 -0
  72. package/site/src/components/Warning.svelte +19 -0
  73. package/site/src/components/index.js +9 -0
  74. package/site/src/components/search/SearchDialog.svelte +305 -0
  75. package/site/src/components/search/SearchInput.svelte +61 -0
  76. package/site/src/components/search/focus.js +68 -0
  77. package/site/src/components/search/index.js +3 -0
  78. package/site/src/components/search/stores.js +4 -0
  79. package/site/src/hooks.ts +11 -0
  80. package/site/src/lib/graphql-language.js +45 -0
  81. package/site/src/lib/highlight.js +5 -0
  82. package/site/src/lib/loadContent.js +233 -0
  83. package/site/src/lib/loadOutline.js +127 -0
  84. package/site/src/lib/mode.js +20 -0
  85. package/site/src/routes/_blank.svelte +1 -0
  86. package/site/src/routes/_content.js +6 -0
  87. package/site/src/routes/_page.svelte +551 -0
  88. package/site/src/routes/api/cli.svx +36 -0
  89. package/site/src/routes/api/config.svx +61 -0
  90. package/site/src/routes/api/fragment/inline.svx +118 -0
  91. package/site/src/routes/api/fragment/store.svx +166 -0
  92. package/site/src/routes/api/graphql.svx +137 -0
  93. package/site/src/routes/api/mutation/inline.svx +153 -0
  94. package/site/src/routes/api/mutation/store.svx +99 -0
  95. package/site/src/routes/api/preprocessor.svx +30 -0
  96. package/site/src/routes/api/query/inline.svx +219 -0
  97. package/site/src/routes/api/query/store.svx +299 -0
  98. package/site/src/routes/api/subscription/inline.svx +115 -0
  99. package/site/src/routes/api/subscription/store.svx +37 -0
  100. package/site/src/routes/api/welcome.svx +144 -0
  101. package/site/src/routes/guides/authentication.svx +69 -0
  102. package/site/src/routes/guides/caching-data.svx +186 -0
  103. package/site/src/routes/guides/contributing.svx +210 -0
  104. package/site/src/routes/guides/faq.svx +92 -0
  105. package/site/src/routes/guides/migrating-to-0.15.0.svx +92 -0
  106. package/site/src/routes/guides/pagination.svx +132 -0
  107. package/site/src/routes/guides/persisted-queries.svx +100 -0
  108. package/site/src/routes/guides/setting-up-your-project.svx +153 -0
  109. package/site/src/routes/guides/typescript.svx +69 -0
  110. package/site/src/routes/guides/working-with-graphql.svx +191 -0
  111. package/site/src/routes/index.svelte +629 -0
  112. package/site/src/routes/intro/fetching-data.svx +251 -0
  113. package/site/src/routes/intro/fragments.svx +227 -0
  114. package/site/src/routes/intro/mutations.svx +158 -0
  115. package/site/src/routes/intro/pagination.svx +251 -0
  116. package/site/src/routes/intro/welcome.svx +40 -0
  117. package/site/src/routes/setMode.ts +12 -0
  118. package/site/src/sections/list-operations.svx +93 -0
  119. package/site/src/sections/subscription-client.svx +93 -0
  120. package/site/static/favicon.png +0 -0
  121. package/site/static/images/github.svg +1 -0
  122. package/site/static/images/houdini-v5.png +0 -0
  123. package/site/static/images/logo.svg +1 -0
  124. package/site/static/images/pokedex-preview.png +0 -0
  125. package/site/static/robots.txt +2 -0
  126. package/site/static/styles/code.css +76 -0
  127. package/site/static/styles/md.css +122 -0
  128. package/site/static/styles/reset.css +227 -0
  129. package/site/svelte.config.js +60 -0
  130. package/site/tsconfig.json +35 -0
  131. package/site/vite.config.js +29 -0
  132. package/src/cmd/generators/runtime/adapter.ts +1 -1
  133. package/src/cmd/generators/stores/pagination.ts +4 -18
  134. package/src/cmd/generators/stores/query.ts +1 -4
  135. package/src/cmd/init.ts +1 -1
  136. package/src/cmd/transforms/paginate.ts +2 -1
  137. package/src/cmd/validators/typeCheck.ts +39 -25
  138. package/src/runtime/adapter.ts +2 -2
  139. package/src/runtime/cache/cache.ts +3 -4
  140. package/src/runtime/inline/fragment.ts +8 -4
  141. package/src/runtime/inline/query.ts +4 -2
  142. package/src/runtime/lib/config.ts +2 -2
  143. package/src/runtime/lib/pagination.ts +183 -122
  144. package/src/runtime/lib/session.ts +60 -0
  145. package/src/runtime/stores/fragment.ts +86 -10
  146. package/src/runtime/stores/mutation.ts +27 -14
  147. package/src/runtime/stores/query.ts +112 -65
package/.prettierignore CHANGED
@@ -1,3 +1,4 @@
1
1
  .yarn/
2
2
  **/build/**
3
3
  README.md
4
+ .github/**
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # houdini
2
2
 
3
+ ## 0.15.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [#443](https://github.com/HoudiniGraphql/houdini/pull/443) [`801d7e8`](https://github.com/HoudiniGraphql/houdini/commit/801d7e87f5199cb5e352001826d8f2d4c454bcc3) Thanks [@jycouet](https://github.com/jycouet)! - warn user when Node interface is not properly defined and throw an error on Node usage (when not properly defined)
8
+
9
+ ## 0.15.8
10
+
11
+ ### Patch Changes
12
+
13
+ - [#434](https://github.com/HoudiniGraphql/houdini/pull/434) [`ebeb90e`](https://github.com/HoudiniGraphql/houdini/commit/ebeb90e1a9528b1b327bc161d26dc962ba7812bd) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - prevent store information from leaking across requests boundaries
14
+
15
+ * [#434](https://github.com/HoudiniGraphql/houdini/pull/434) [`ebeb90e`](https://github.com/HoudiniGraphql/houdini/commit/ebeb90e1a9528b1b327bc161d26dc962ba7812bd) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - updated type definition for config file to allow for missing marshal/unmarshal functions
16
+
17
+ ## 0.15.7
18
+
19
+ ### Patch Changes
20
+
21
+ - [#429](https://github.com/HoudiniGraphql/houdini/pull/429) [`d6d5c50`](https://github.com/HoudiniGraphql/houdini/commit/d6d5c50c2f4f0365a5939799fbcab4205fd99317) Thanks [@jycouet](https://github.com/jycouet)! - fix: unsub only when you have no active stores
22
+
3
23
  ## 0.15.6
4
24
 
5
25
  ### Patch Changes
@@ -36,7 +36,7 @@ export function goTo(location, options) {
36
36
 
37
37
  export const isBrowser = process.browser
38
38
 
39
- export const clientStarted = true; // Not tested in Sapper.
39
+ export const clientStarted = true;
40
40
 
41
41
  export const isPrerender = false
42
42
  `;
@@ -2,7 +2,7 @@ import { Config } from '../../../common';
2
2
  import { CollectedGraphQLDocument } from '../../types';
3
3
  export default function pagination(config: Config, doc: CollectedGraphQLDocument, which: 'fragment' | 'query'): {
4
4
  types: string;
5
- methods: {};
5
+ methods: string[];
6
6
  typeImports: string;
7
7
  storeExtras: string;
8
8
  };
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  function pagination(config, doc, which) {
4
4
  // figure out the extra methods and their types when there's pagination
5
- let methods = {};
5
+ let methods = [];
6
6
  let types = '';
7
7
  let typeImports = '';
8
8
  let storeExtras = '{}';
@@ -15,11 +15,7 @@ function pagination(config, doc, which) {
15
15
  types = `{
16
16
  loadNextPage: (context: HoudiniFetchContext, limit?: number) => Promise<void>
17
17
  }`;
18
- methods = {
19
- loadNextPage: 'loadNextPage',
20
- fetch: 'refetch',
21
- loading: 'loading',
22
- };
18
+ methods = ['loadNextPage', 'fetch', 'loading'];
23
19
  }
24
20
  // cursor pagination
25
21
  else if (paginationMethod === 'cursor') {
@@ -34,24 +30,14 @@ import type { PageInfo } from '../runtime/lib/utils'`;
34
30
  loadNextPage: (context: HoudiniFetchContext, pageCount?: number, after?: string | number) => Promise<void>
35
31
  ${which === 'query' ? 'pageInfo: Readable<PageInfo>' : ''}
36
32
  }`;
37
- methods = {
38
- loadNextPage: 'loadNextPage',
39
- pageInfo: 'pageInfo',
40
- fetch: 'refetch',
41
- loading: 'loading',
42
- };
33
+ methods = ['loadNextPage', 'fetch', 'loading'];
43
34
  // backwards cursor pagination
44
35
  }
45
36
  else {
46
37
  types = `{
47
38
  loadPreviousPage: (context: HoudiniFetchContext, pageCount?: number, before?: string) => Promise<void>
48
39
  }`;
49
- methods = {
50
- loadPreviousPage: 'loadPreviousPage',
51
- pageInfo: 'pageInfo',
52
- fetch: 'refetch',
53
- loading: 'loading',
54
- };
40
+ methods = ['loadPreviousPage', 'fetch', 'loading'];
55
41
  }
56
42
  }
57
43
  return {
@@ -48,7 +48,7 @@ const factory = () => queryStore({
48
48
  config: defaultConfigValues(houdiniConfig),
49
49
  storeName: ${JSON.stringify(storeName)},
50
50
  paginated: ${JSON.stringify(Boolean(doc.refetch?.paginated))},
51
- paginationMethods: ${JSON.stringify(paginationExtras.methods, null, 4).replaceAll('\n', '\n ')}
51
+ paginationMethods: ${JSON.stringify(paginationExtras.methods)},
52
52
  })
53
53
 
54
54
  export const ${storeName} = factory()
package/build/cmd/init.js CHANGED
@@ -381,7 +381,7 @@ async function graphqlRCFile(targetPath) {
381
381
  - ./schema.graphql
382
382
  - ./$houdini/graphql/schema.graphql
383
383
  documents:
384
- - **/*.gql
384
+ - '**/*.gql'
385
385
  - ./$houdini/graphql/documents.gql
386
386
  `;
387
387
  await updateFile({
@@ -25,12 +25,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.pageInfoSelection = void 0;
27
27
  // externals
28
- const graphql = __importStar(require("graphql"));
29
28
  const common_1 = require("../../common");
30
29
  const types_1 = require("../../runtime/lib/types");
31
30
  // locals
32
31
  const types_2 = require("../types");
33
32
  const utils_1 = require("../utils");
33
+ const graphql = __importStar(require("graphql"));
34
34
  // paginate transform adds the necessary fields for a paginated field
35
35
  async function paginate(config, documents) {
36
36
  // we're going to have to add documents to the list so collect them here and we'll add them when we're done
@@ -1,3 +1,5 @@
1
1
  import { Config } from '../../common';
2
2
  import { CollectedGraphQLDocument } from '../types';
3
+ import * as graphql from 'graphql';
3
4
  export default function typeCheck(config: Config, docs: CollectedGraphQLDocument[]): Promise<void>;
5
+ export declare function getAndVerifyNodeInterface(config: Config): graphql.GraphQLInterfaceType | null;
@@ -23,26 +23,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getAndVerifyNodeInterface = void 0;
26
27
  // externals
27
- const graphql = __importStar(require("graphql"));
28
28
  // locals
29
29
  const common_1 = require("../../common");
30
- const types_1 = require("../types");
31
30
  const fragmentVariables_1 = require("../transforms/fragmentVariables");
32
- const utils_1 = require("../utils");
33
31
  const list_1 = require("../transforms/list");
32
+ const types_1 = require("../types");
33
+ const utils_1 = require("../utils");
34
+ const graphql = __importStar(require("graphql"));
34
35
  // typeCheck verifies that the documents are valid instead of waiting
35
36
  // for the compiler to fail later down the line.
36
37
  async function typeCheck(config, docs) {
37
38
  // wrap the errors we run into in a HoudiniError
38
39
  const errors = [];
39
- // verify the node interface (if it exists)
40
- try {
41
- verifyNodeInterface(config);
42
- }
43
- catch (e) {
44
- throw (0, types_1.HoudiniErrorTodo)("There is a problem with your project's schema: " + e.message);
45
- }
46
40
  // we need to catch errors in the list API. this means that a user
47
41
  // must provide parentID if they are using a list that is not all-objects
48
42
  // from root. figure out which lists are "free" (ie, can be applied without a parentID arg)
@@ -580,7 +574,7 @@ function nodeDirectives(config, directives) {
580
574
  let possibleNodes = [queryType?.name || ''];
581
575
  const customTypes = Object.keys(config.typeConfig || {});
582
576
  // check if there's a node interface
583
- const nodeInterface = config.schema.getType('Node');
577
+ const nodeInterface = getAndVerifyNodeInterface(config);
584
578
  if (nodeInterface) {
585
579
  const { objects, interfaces } = config.schema.getImplementations(nodeInterface);
586
580
  possibleNodes.push(...objects.map((object) => object.name), ...interfaces.map((object) => object.name));
@@ -619,52 +613,74 @@ function nodeDirectives(config, directives) {
619
613
  };
620
614
  };
621
615
  }
622
- function verifyNodeInterface(config) {
616
+ function getAndVerifyNodeInterface(config) {
623
617
  const { schema } = config;
624
618
  // look for Node
625
619
  const nodeInterface = schema.getType('Node');
626
620
  // if there is no node interface don't do anything else
627
621
  if (!nodeInterface) {
628
- return;
622
+ return null;
629
623
  }
630
624
  // make sure its an interface
631
625
  if (!graphql.isInterfaceType(nodeInterface)) {
632
- throw new Error(invalidNodeFieldMessage);
626
+ displayInvalidNodeFieldMessage(config.logLevel);
627
+ return null;
633
628
  }
634
629
  // look for a field on the query type to look up a node by id
635
630
  const queryType = schema.getQueryType();
636
631
  if (!queryType) {
637
- throw new Error(invalidNodeFieldMessage);
632
+ displayInvalidNodeFieldMessage(config.logLevel);
633
+ return null;
638
634
  }
639
635
  // look for a node field
640
636
  const nodeField = queryType.getFields()['node'];
641
637
  if (!nodeField) {
642
- throw new Error(invalidNodeFieldMessage);
638
+ displayInvalidNodeFieldMessage(config.logLevel);
639
+ return null;
643
640
  }
644
641
  // there needs to be an arg on the field called id
645
642
  const args = nodeField.args;
646
643
  if (args.length === 0) {
647
- throw new Error(invalidNodeFieldMessage);
644
+ displayInvalidNodeFieldMessage(config.logLevel);
645
+ return null;
648
646
  }
649
647
  // look for the id arg
650
648
  const idArg = args.find((arg) => arg.name === 'id');
651
649
  if (!idArg) {
652
- throw new Error(invalidNodeFieldMessage);
650
+ displayInvalidNodeFieldMessage(config.logLevel);
651
+ return null;
653
652
  }
654
653
  // make sure that the id arg takes an ID
655
654
  const idType = (0, utils_1.unwrapType)(config, idArg.type);
656
655
  // make sure its an ID
657
656
  if (idType.type.name !== 'ID') {
658
- throw new Error(invalidNodeFieldMessage);
657
+ displayInvalidNodeFieldMessage(config.logLevel);
658
+ return null;
659
659
  }
660
660
  // make sure that the node field returns a Node
661
661
  const fieldReturnType = (0, utils_1.unwrapType)(config, nodeField.type);
662
662
  if (fieldReturnType.type.name !== 'Node') {
663
- throw new Error(invalidNodeFieldMessage);
663
+ displayInvalidNodeFieldMessage(config.logLevel);
664
+ return null;
665
+ }
666
+ return nodeInterface;
667
+ }
668
+ exports.getAndVerifyNodeInterface = getAndVerifyNodeInterface;
669
+ let nbInvalidNodeFieldMessageDisplayed = 0;
670
+ function displayInvalidNodeFieldMessage(logLevel) {
671
+ // We want to display the message only once.
672
+ if (nbInvalidNodeFieldMessageDisplayed === 0) {
673
+ if (logLevel === common_1.LogLevel.Full) {
674
+ console.warn(invalidNodeFieldMessage);
675
+ }
676
+ else {
677
+ console.warn(invalidNodeFieldMessageLight);
678
+ }
664
679
  }
680
+ nbInvalidNodeFieldMessageDisplayed++;
665
681
  }
666
- const invalidNodeFieldMessage = `
667
- Your project defines a Node interface but it does not conform to the Global Identification Spec.
682
+ const invalidNodeFieldMessageLight = `⚠️ Your Node interface is not properly defined, please fix your schema to be able to use this interface. (For more info, add flag "-l full")`;
683
+ const invalidNodeFieldMessage = `⚠️ Your project defines a Node interface but it does not conform to the Global Identification Spec.
668
684
 
669
685
  If you are trying to provide the Node interface and its field, they must look like the following:
670
686