houdini-svelte 1.0.5 → 1.0.7

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.
@@ -151537,6 +151537,12 @@ function inlineType({
151537
151537
  includeFragments,
151538
151538
  allOptional
151539
151539
  });
151540
+ const hasIncludeOrSkipDirective = selection2.directives && selection2.directives.filter(
151541
+ (directive) => directive.name.value === "include" || directive.name.value === "skip"
151542
+ ).length > 0;
151543
+ if (hasIncludeOrSkipDirective) {
151544
+ attributeType = AST10.tsUnionType([attributeType, AST10.tsUndefinedKeyword()]);
151545
+ }
151540
151546
  const prop = readonlyProperty(
151541
151547
  AST10.tsPropertySignature(
151542
151548
  AST10.identifier(attributeName),
@@ -152681,40 +152687,54 @@ async function addID(config22, documents) {
152681
152687
  );
152682
152688
  const field = type.getFields()[node2.name.value];
152683
152689
  const fieldType = unwrapType2(config22, field.type).type;
152684
- if (node2.selectionSet?.selections.length > 0) {
152685
- if (!graphql23.isObjectType(fieldType) && !graphql23.isInterfaceType(fieldType)) {
152686
- return;
152687
- }
152688
- const keyFields = config22.keyFieldsForType(fieldType.name);
152689
- if (keyFields.find((key2) => !fieldType.getFields()[key2])) {
152690
- return;
152691
- }
152692
- const selections = [...node2.selectionSet.selections];
152693
- for (const keyField of keyFields) {
152694
- if (node2.selectionSet.selections.find(
152695
- (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
152696
- )) {
152697
- continue;
152698
- }
152699
- selections.push({
152700
- kind: graphql23.Kind.FIELD,
152701
- name: {
152702
- kind: graphql23.Kind.NAME,
152703
- value: keyField
152704
- }
152705
- });
152706
- }
152707
- return {
152708
- ...node2,
152709
- selectionSet: {
152710
- ...node2.selectionSet,
152711
- selections
152712
- }
152713
- };
152690
+ return addKeysToSelection(config22, node2, fieldType);
152691
+ },
152692
+ InlineFragment(node2) {
152693
+ if (!node2.selectionSet || !node2.typeCondition) {
152694
+ return;
152714
152695
  }
152696
+ const fragmentType = config22.schema.getType(node2.typeCondition.name.value);
152697
+ if (!fragmentType) {
152698
+ return;
152699
+ }
152700
+ return addKeysToSelection(config22, node2, fragmentType);
152701
+ }
152702
+ });
152703
+ }
152704
+ }
152705
+ function addKeysToSelection(config22, node2, fieldType) {
152706
+ if (!node2.selectionSet || node2.selectionSet.selections.length == 0) {
152707
+ return;
152708
+ }
152709
+ if (!graphql23.isObjectType(fieldType) && !graphql23.isInterfaceType(fieldType)) {
152710
+ return;
152711
+ }
152712
+ const keyFields = config22.keyFieldsForType(fieldType.name);
152713
+ if (keyFields.find((key) => !fieldType.getFields()[key])) {
152714
+ return;
152715
+ }
152716
+ const selections = [...node2.selectionSet.selections];
152717
+ for (const keyField of keyFields) {
152718
+ if (node2.selectionSet.selections.find(
152719
+ (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
152720
+ )) {
152721
+ continue;
152722
+ }
152723
+ selections.push({
152724
+ kind: graphql23.Kind.FIELD,
152725
+ name: {
152726
+ kind: graphql23.Kind.NAME,
152727
+ value: keyField
152715
152728
  }
152716
152729
  });
152717
152730
  }
152731
+ return {
152732
+ ...node2,
152733
+ selectionSet: {
152734
+ ...node2.selectionSet,
152735
+ selections
152736
+ }
152737
+ };
152718
152738
  }
152719
152739
  var graphql24 = __toESM3(require_graphql22(), 1);
152720
152740
  async function typeCheck(config22, docs) {
@@ -151528,6 +151528,12 @@ function inlineType({
151528
151528
  includeFragments,
151529
151529
  allOptional
151530
151530
  });
151531
+ const hasIncludeOrSkipDirective = selection2.directives && selection2.directives.filter(
151532
+ (directive) => directive.name.value === "include" || directive.name.value === "skip"
151533
+ ).length > 0;
151534
+ if (hasIncludeOrSkipDirective) {
151535
+ attributeType = AST10.tsUnionType([attributeType, AST10.tsUndefinedKeyword()]);
151536
+ }
151531
151537
  const prop = readonlyProperty(
151532
151538
  AST10.tsPropertySignature(
151533
151539
  AST10.identifier(attributeName),
@@ -152672,40 +152678,54 @@ async function addID(config22, documents) {
152672
152678
  );
152673
152679
  const field = type.getFields()[node2.name.value];
152674
152680
  const fieldType = unwrapType2(config22, field.type).type;
152675
- if (node2.selectionSet?.selections.length > 0) {
152676
- if (!graphql23.isObjectType(fieldType) && !graphql23.isInterfaceType(fieldType)) {
152677
- return;
152678
- }
152679
- const keyFields = config22.keyFieldsForType(fieldType.name);
152680
- if (keyFields.find((key2) => !fieldType.getFields()[key2])) {
152681
- return;
152682
- }
152683
- const selections = [...node2.selectionSet.selections];
152684
- for (const keyField of keyFields) {
152685
- if (node2.selectionSet.selections.find(
152686
- (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
152687
- )) {
152688
- continue;
152689
- }
152690
- selections.push({
152691
- kind: graphql23.Kind.FIELD,
152692
- name: {
152693
- kind: graphql23.Kind.NAME,
152694
- value: keyField
152695
- }
152696
- });
152697
- }
152698
- return {
152699
- ...node2,
152700
- selectionSet: {
152701
- ...node2.selectionSet,
152702
- selections
152703
- }
152704
- };
152681
+ return addKeysToSelection(config22, node2, fieldType);
152682
+ },
152683
+ InlineFragment(node2) {
152684
+ if (!node2.selectionSet || !node2.typeCondition) {
152685
+ return;
152705
152686
  }
152687
+ const fragmentType = config22.schema.getType(node2.typeCondition.name.value);
152688
+ if (!fragmentType) {
152689
+ return;
152690
+ }
152691
+ return addKeysToSelection(config22, node2, fragmentType);
152692
+ }
152693
+ });
152694
+ }
152695
+ }
152696
+ function addKeysToSelection(config22, node2, fieldType) {
152697
+ if (!node2.selectionSet || node2.selectionSet.selections.length == 0) {
152698
+ return;
152699
+ }
152700
+ if (!graphql23.isObjectType(fieldType) && !graphql23.isInterfaceType(fieldType)) {
152701
+ return;
152702
+ }
152703
+ const keyFields = config22.keyFieldsForType(fieldType.name);
152704
+ if (keyFields.find((key) => !fieldType.getFields()[key])) {
152705
+ return;
152706
+ }
152707
+ const selections = [...node2.selectionSet.selections];
152708
+ for (const keyField of keyFields) {
152709
+ if (node2.selectionSet.selections.find(
152710
+ (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
152711
+ )) {
152712
+ continue;
152713
+ }
152714
+ selections.push({
152715
+ kind: graphql23.Kind.FIELD,
152716
+ name: {
152717
+ kind: graphql23.Kind.NAME,
152718
+ value: keyField
152706
152719
  }
152707
152720
  });
152708
152721
  }
152722
+ return {
152723
+ ...node2,
152724
+ selectionSet: {
152725
+ ...node2.selectionSet,
152726
+ selections
152727
+ }
152728
+ };
152709
152729
  }
152710
152730
  var graphql24 = __toESM3(require_graphql22(), 1);
152711
152731
  async function typeCheck(config22, docs) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-svelte",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "The svelte plugin for houdini",
5
5
  "keywords": [
6
6
  "typescript",
@@ -32,7 +32,7 @@
32
32
  "rollup": "^3.7.4",
33
33
  "svelte": "^3.55.1",
34
34
  "vite": "^4.1.1",
35
- "houdini": "^1.0.5"
35
+ "houdini": "^1.0.7"
36
36
  },
37
37
  "files": [
38
38
  "build"