houdini 0.15.8 → 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 (84) hide show
  1. package/.prettierignore +1 -0
  2. package/CHANGELOG.md +6 -0
  3. package/build/cmd/transforms/paginate.js +1 -1
  4. package/build/cmd/validators/typeCheck.d.ts +2 -0
  5. package/build/cmd/validators/typeCheck.js +38 -22
  6. package/build/cmd.js +347 -150
  7. package/package.json +2 -1
  8. package/site/.env.example +1 -0
  9. package/site/.eslintrc.cjs +20 -0
  10. package/site/.husky/pre-commit +4 -0
  11. package/site/.prettierrc +7 -0
  12. package/site/README.md +26 -0
  13. package/site/package.json +51 -0
  14. package/site/src/app.d.ts +21 -0
  15. package/site/src/app.html +25 -0
  16. package/site/src/components/APIShowcase.svelte +109 -0
  17. package/site/src/components/DeepDive.svelte +50 -0
  18. package/site/src/components/GraphQLExplained.svelte +50 -0
  19. package/site/src/components/HeaderWithMode.svelte +53 -0
  20. package/site/src/components/Icon.svelte +38 -0
  21. package/site/src/components/SEO.svelte +19 -0
  22. package/site/src/components/Transformation.svelte +25 -0
  23. package/site/src/components/Warning.svelte +19 -0
  24. package/site/src/components/index.js +9 -0
  25. package/site/src/components/search/SearchDialog.svelte +305 -0
  26. package/site/src/components/search/SearchInput.svelte +61 -0
  27. package/site/src/components/search/focus.js +68 -0
  28. package/site/src/components/search/index.js +3 -0
  29. package/site/src/components/search/stores.js +4 -0
  30. package/site/src/hooks.ts +11 -0
  31. package/site/src/lib/graphql-language.js +45 -0
  32. package/site/src/lib/highlight.js +5 -0
  33. package/site/src/lib/loadContent.js +233 -0
  34. package/site/src/lib/loadOutline.js +127 -0
  35. package/site/src/lib/mode.js +20 -0
  36. package/site/src/routes/_blank.svelte +1 -0
  37. package/site/src/routes/_content.js +6 -0
  38. package/site/src/routes/_page.svelte +551 -0
  39. package/site/src/routes/api/cli.svx +36 -0
  40. package/site/src/routes/api/config.svx +61 -0
  41. package/site/src/routes/api/fragment/inline.svx +118 -0
  42. package/site/src/routes/api/fragment/store.svx +166 -0
  43. package/site/src/routes/api/graphql.svx +137 -0
  44. package/site/src/routes/api/mutation/inline.svx +153 -0
  45. package/site/src/routes/api/mutation/store.svx +99 -0
  46. package/site/src/routes/api/preprocessor.svx +30 -0
  47. package/site/src/routes/api/query/inline.svx +219 -0
  48. package/site/src/routes/api/query/store.svx +299 -0
  49. package/site/src/routes/api/subscription/inline.svx +115 -0
  50. package/site/src/routes/api/subscription/store.svx +37 -0
  51. package/site/src/routes/api/welcome.svx +144 -0
  52. package/site/src/routes/guides/authentication.svx +69 -0
  53. package/site/src/routes/guides/caching-data.svx +186 -0
  54. package/site/src/routes/guides/contributing.svx +210 -0
  55. package/site/src/routes/guides/faq.svx +92 -0
  56. package/site/src/routes/guides/migrating-to-0.15.0.svx +92 -0
  57. package/site/src/routes/guides/pagination.svx +132 -0
  58. package/site/src/routes/guides/persisted-queries.svx +100 -0
  59. package/site/src/routes/guides/setting-up-your-project.svx +153 -0
  60. package/site/src/routes/guides/typescript.svx +69 -0
  61. package/site/src/routes/guides/working-with-graphql.svx +191 -0
  62. package/site/src/routes/index.svelte +629 -0
  63. package/site/src/routes/intro/fetching-data.svx +251 -0
  64. package/site/src/routes/intro/fragments.svx +227 -0
  65. package/site/src/routes/intro/mutations.svx +158 -0
  66. package/site/src/routes/intro/pagination.svx +251 -0
  67. package/site/src/routes/intro/welcome.svx +40 -0
  68. package/site/src/routes/setMode.ts +12 -0
  69. package/site/src/sections/list-operations.svx +93 -0
  70. package/site/src/sections/subscription-client.svx +93 -0
  71. package/site/static/favicon.png +0 -0
  72. package/site/static/images/github.svg +1 -0
  73. package/site/static/images/houdini-v5.png +0 -0
  74. package/site/static/images/logo.svg +1 -0
  75. package/site/static/images/pokedex-preview.png +0 -0
  76. package/site/static/robots.txt +2 -0
  77. package/site/static/styles/code.css +76 -0
  78. package/site/static/styles/md.css +122 -0
  79. package/site/static/styles/reset.css +227 -0
  80. package/site/svelte.config.js +60 -0
  81. package/site/tsconfig.json +35 -0
  82. package/site/vite.config.js +29 -0
  83. package/src/cmd/transforms/paginate.ts +2 -1
  84. package/src/cmd/validators/typeCheck.ts +39 -25
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,11 @@
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
+
3
9
  ## 0.15.8
4
10
 
5
11
  ### Patch Changes
@@ -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