houdini 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.
@@ -75961,6 +75961,12 @@ function inlineType({
75961
75961
  includeFragments,
75962
75962
  allOptional
75963
75963
  });
75964
+ const hasIncludeOrSkipDirective = selection2.directives && selection2.directives.filter(
75965
+ (directive) => directive.name.value === "include" || directive.name.value === "skip"
75966
+ ).length > 0;
75967
+ if (hasIncludeOrSkipDirective) {
75968
+ attributeType = AST10.tsUnionType([attributeType, AST10.tsUndefinedKeyword()]);
75969
+ }
75964
75970
  const prop = readonlyProperty(
75965
75971
  AST10.tsPropertySignature(
75966
75972
  AST10.identifier(attributeName),
@@ -77125,40 +77131,54 @@ async function addID(config2, documents) {
77125
77131
  );
77126
77132
  const field = type.getFields()[node.name.value];
77127
77133
  const fieldType = unwrapType(config2, field.type).type;
77128
- if (node.selectionSet?.selections.length > 0) {
77129
- if (!graphql24.isObjectType(fieldType) && !graphql24.isInterfaceType(fieldType)) {
77130
- return;
77131
- }
77132
- const keyFields = config2.keyFieldsForType(fieldType.name);
77133
- if (keyFields.find((key2) => !fieldType.getFields()[key2])) {
77134
- return;
77135
- }
77136
- const selections = [...node.selectionSet.selections];
77137
- for (const keyField of keyFields) {
77138
- if (node.selectionSet.selections.find(
77139
- (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
77140
- )) {
77141
- continue;
77142
- }
77143
- selections.push({
77144
- kind: graphql24.Kind.FIELD,
77145
- name: {
77146
- kind: graphql24.Kind.NAME,
77147
- value: keyField
77148
- }
77149
- });
77150
- }
77151
- return {
77152
- ...node,
77153
- selectionSet: {
77154
- ...node.selectionSet,
77155
- selections
77156
- }
77157
- };
77134
+ return addKeysToSelection(config2, node, fieldType);
77135
+ },
77136
+ InlineFragment(node) {
77137
+ if (!node.selectionSet || !node.typeCondition) {
77138
+ return;
77158
77139
  }
77140
+ const fragmentType = config2.schema.getType(node.typeCondition.name.value);
77141
+ if (!fragmentType) {
77142
+ return;
77143
+ }
77144
+ return addKeysToSelection(config2, node, fragmentType);
77145
+ }
77146
+ });
77147
+ }
77148
+ }
77149
+ function addKeysToSelection(config2, node, fieldType) {
77150
+ if (!node.selectionSet || node.selectionSet.selections.length == 0) {
77151
+ return;
77152
+ }
77153
+ if (!graphql24.isObjectType(fieldType) && !graphql24.isInterfaceType(fieldType)) {
77154
+ return;
77155
+ }
77156
+ const keyFields = config2.keyFieldsForType(fieldType.name);
77157
+ if (keyFields.find((key) => !fieldType.getFields()[key])) {
77158
+ return;
77159
+ }
77160
+ const selections = [...node.selectionSet.selections];
77161
+ for (const keyField of keyFields) {
77162
+ if (node.selectionSet.selections.find(
77163
+ (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
77164
+ )) {
77165
+ continue;
77166
+ }
77167
+ selections.push({
77168
+ kind: graphql24.Kind.FIELD,
77169
+ name: {
77170
+ kind: graphql24.Kind.NAME,
77171
+ value: keyField
77159
77172
  }
77160
77173
  });
77161
77174
  }
77175
+ return {
77176
+ ...node,
77177
+ selectionSet: {
77178
+ ...node.selectionSet,
77179
+ selections
77180
+ }
77181
+ };
77162
77182
  }
77163
77183
 
77164
77184
  // src/codegen/validators/typeCheck.ts
@@ -78721,8 +78741,8 @@ async function updatePackageJSON(targetPath) {
78721
78741
  }
78722
78742
  packageJSON.devDependencies = {
78723
78743
  ...packageJSON.devDependencies,
78724
- houdini: "^1.0.5",
78725
- "houdini-svelte": "^1.0.5"
78744
+ houdini: "^1.0.7",
78745
+ "houdini-svelte": "^1.0.7"
78726
78746
  };
78727
78747
  await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
78728
78748
  }
@@ -75966,6 +75966,12 @@ function inlineType({
75966
75966
  includeFragments,
75967
75967
  allOptional
75968
75968
  });
75969
+ const hasIncludeOrSkipDirective = selection2.directives && selection2.directives.filter(
75970
+ (directive) => directive.name.value === "include" || directive.name.value === "skip"
75971
+ ).length > 0;
75972
+ if (hasIncludeOrSkipDirective) {
75973
+ attributeType = AST10.tsUnionType([attributeType, AST10.tsUndefinedKeyword()]);
75974
+ }
75969
75975
  const prop = readonlyProperty(
75970
75976
  AST10.tsPropertySignature(
75971
75977
  AST10.identifier(attributeName),
@@ -77130,40 +77136,54 @@ async function addID(config2, documents) {
77130
77136
  );
77131
77137
  const field = type.getFields()[node.name.value];
77132
77138
  const fieldType = unwrapType(config2, field.type).type;
77133
- if (node.selectionSet?.selections.length > 0) {
77134
- if (!graphql24.isObjectType(fieldType) && !graphql24.isInterfaceType(fieldType)) {
77135
- return;
77136
- }
77137
- const keyFields = config2.keyFieldsForType(fieldType.name);
77138
- if (keyFields.find((key2) => !fieldType.getFields()[key2])) {
77139
- return;
77140
- }
77141
- const selections = [...node.selectionSet.selections];
77142
- for (const keyField of keyFields) {
77143
- if (node.selectionSet.selections.find(
77144
- (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
77145
- )) {
77146
- continue;
77147
- }
77148
- selections.push({
77149
- kind: graphql24.Kind.FIELD,
77150
- name: {
77151
- kind: graphql24.Kind.NAME,
77152
- value: keyField
77153
- }
77154
- });
77155
- }
77156
- return {
77157
- ...node,
77158
- selectionSet: {
77159
- ...node.selectionSet,
77160
- selections
77161
- }
77162
- };
77139
+ return addKeysToSelection(config2, node, fieldType);
77140
+ },
77141
+ InlineFragment(node) {
77142
+ if (!node.selectionSet || !node.typeCondition) {
77143
+ return;
77163
77144
  }
77145
+ const fragmentType = config2.schema.getType(node.typeCondition.name.value);
77146
+ if (!fragmentType) {
77147
+ return;
77148
+ }
77149
+ return addKeysToSelection(config2, node, fragmentType);
77150
+ }
77151
+ });
77152
+ }
77153
+ }
77154
+ function addKeysToSelection(config2, node, fieldType) {
77155
+ if (!node.selectionSet || node.selectionSet.selections.length == 0) {
77156
+ return;
77157
+ }
77158
+ if (!graphql24.isObjectType(fieldType) && !graphql24.isInterfaceType(fieldType)) {
77159
+ return;
77160
+ }
77161
+ const keyFields = config2.keyFieldsForType(fieldType.name);
77162
+ if (keyFields.find((key) => !fieldType.getFields()[key])) {
77163
+ return;
77164
+ }
77165
+ const selections = [...node.selectionSet.selections];
77166
+ for (const keyField of keyFields) {
77167
+ if (node.selectionSet.selections.find(
77168
+ (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
77169
+ )) {
77170
+ continue;
77171
+ }
77172
+ selections.push({
77173
+ kind: graphql24.Kind.FIELD,
77174
+ name: {
77175
+ kind: graphql24.Kind.NAME,
77176
+ value: keyField
77164
77177
  }
77165
77178
  });
77166
77179
  }
77180
+ return {
77181
+ ...node,
77182
+ selectionSet: {
77183
+ ...node.selectionSet,
77184
+ selections
77185
+ }
77186
+ };
77167
77187
  }
77168
77188
 
77169
77189
  // src/codegen/validators/typeCheck.ts
@@ -78726,8 +78746,8 @@ async function updatePackageJSON(targetPath) {
78726
78746
  }
78727
78747
  packageJSON.devDependencies = {
78728
78748
  ...packageJSON.devDependencies,
78729
- houdini: "^1.0.5",
78730
- "houdini-svelte": "^1.0.5"
78749
+ houdini: "^1.0.7",
78750
+ "houdini-svelte": "^1.0.7"
78731
78751
  };
78732
78752
  await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
78733
78753
  }
@@ -59714,6 +59714,12 @@ function inlineType({
59714
59714
  includeFragments,
59715
59715
  allOptional
59716
59716
  });
59717
+ const hasIncludeOrSkipDirective = selection2.directives && selection2.directives.filter(
59718
+ (directive) => directive.name.value === "include" || directive.name.value === "skip"
59719
+ ).length > 0;
59720
+ if (hasIncludeOrSkipDirective) {
59721
+ attributeType = AST10.tsUnionType([attributeType, AST10.tsUndefinedKeyword()]);
59722
+ }
59717
59723
  const prop = readonlyProperty(
59718
59724
  AST10.tsPropertySignature(
59719
59725
  AST10.identifier(attributeName),
@@ -60878,40 +60884,54 @@ async function addID(config2, documents) {
60878
60884
  );
60879
60885
  const field = type.getFields()[node.name.value];
60880
60886
  const fieldType = unwrapType(config2, field.type).type;
60881
- if (node.selectionSet?.selections.length > 0) {
60882
- if (!graphql23.isObjectType(fieldType) && !graphql23.isInterfaceType(fieldType)) {
60883
- return;
60884
- }
60885
- const keyFields = config2.keyFieldsForType(fieldType.name);
60886
- if (keyFields.find((key2) => !fieldType.getFields()[key2])) {
60887
- return;
60888
- }
60889
- const selections = [...node.selectionSet.selections];
60890
- for (const keyField of keyFields) {
60891
- if (node.selectionSet.selections.find(
60892
- (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
60893
- )) {
60894
- continue;
60895
- }
60896
- selections.push({
60897
- kind: graphql23.Kind.FIELD,
60898
- name: {
60899
- kind: graphql23.Kind.NAME,
60900
- value: keyField
60901
- }
60902
- });
60903
- }
60904
- return {
60905
- ...node,
60906
- selectionSet: {
60907
- ...node.selectionSet,
60908
- selections
60909
- }
60910
- };
60887
+ return addKeysToSelection(config2, node, fieldType);
60888
+ },
60889
+ InlineFragment(node) {
60890
+ if (!node.selectionSet || !node.typeCondition) {
60891
+ return;
60911
60892
  }
60893
+ const fragmentType = config2.schema.getType(node.typeCondition.name.value);
60894
+ if (!fragmentType) {
60895
+ return;
60896
+ }
60897
+ return addKeysToSelection(config2, node, fragmentType);
60898
+ }
60899
+ });
60900
+ }
60901
+ }
60902
+ function addKeysToSelection(config2, node, fieldType) {
60903
+ if (!node.selectionSet || node.selectionSet.selections.length == 0) {
60904
+ return;
60905
+ }
60906
+ if (!graphql23.isObjectType(fieldType) && !graphql23.isInterfaceType(fieldType)) {
60907
+ return;
60908
+ }
60909
+ const keyFields = config2.keyFieldsForType(fieldType.name);
60910
+ if (keyFields.find((key) => !fieldType.getFields()[key])) {
60911
+ return;
60912
+ }
60913
+ const selections = [...node.selectionSet.selections];
60914
+ for (const keyField of keyFields) {
60915
+ if (node.selectionSet.selections.find(
60916
+ (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
60917
+ )) {
60918
+ continue;
60919
+ }
60920
+ selections.push({
60921
+ kind: graphql23.Kind.FIELD,
60922
+ name: {
60923
+ kind: graphql23.Kind.NAME,
60924
+ value: keyField
60912
60925
  }
60913
60926
  });
60914
60927
  }
60928
+ return {
60929
+ ...node,
60930
+ selectionSet: {
60931
+ ...node.selectionSet,
60932
+ selections
60933
+ }
60934
+ };
60915
60935
  }
60916
60936
 
60917
60937
  // src/codegen/validators/typeCheck.ts
@@ -59712,6 +59712,12 @@ function inlineType({
59712
59712
  includeFragments,
59713
59713
  allOptional
59714
59714
  });
59715
+ const hasIncludeOrSkipDirective = selection2.directives && selection2.directives.filter(
59716
+ (directive) => directive.name.value === "include" || directive.name.value === "skip"
59717
+ ).length > 0;
59718
+ if (hasIncludeOrSkipDirective) {
59719
+ attributeType = AST10.tsUnionType([attributeType, AST10.tsUndefinedKeyword()]);
59720
+ }
59715
59721
  const prop = readonlyProperty(
59716
59722
  AST10.tsPropertySignature(
59717
59723
  AST10.identifier(attributeName),
@@ -60876,40 +60882,54 @@ async function addID(config2, documents) {
60876
60882
  );
60877
60883
  const field = type.getFields()[node.name.value];
60878
60884
  const fieldType = unwrapType(config2, field.type).type;
60879
- if (node.selectionSet?.selections.length > 0) {
60880
- if (!graphql23.isObjectType(fieldType) && !graphql23.isInterfaceType(fieldType)) {
60881
- return;
60882
- }
60883
- const keyFields = config2.keyFieldsForType(fieldType.name);
60884
- if (keyFields.find((key2) => !fieldType.getFields()[key2])) {
60885
- return;
60886
- }
60887
- const selections = [...node.selectionSet.selections];
60888
- for (const keyField of keyFields) {
60889
- if (node.selectionSet.selections.find(
60890
- (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
60891
- )) {
60892
- continue;
60893
- }
60894
- selections.push({
60895
- kind: graphql23.Kind.FIELD,
60896
- name: {
60897
- kind: graphql23.Kind.NAME,
60898
- value: keyField
60899
- }
60900
- });
60901
- }
60902
- return {
60903
- ...node,
60904
- selectionSet: {
60905
- ...node.selectionSet,
60906
- selections
60907
- }
60908
- };
60885
+ return addKeysToSelection(config2, node, fieldType);
60886
+ },
60887
+ InlineFragment(node) {
60888
+ if (!node.selectionSet || !node.typeCondition) {
60889
+ return;
60909
60890
  }
60891
+ const fragmentType = config2.schema.getType(node.typeCondition.name.value);
60892
+ if (!fragmentType) {
60893
+ return;
60894
+ }
60895
+ return addKeysToSelection(config2, node, fragmentType);
60896
+ }
60897
+ });
60898
+ }
60899
+ }
60900
+ function addKeysToSelection(config2, node, fieldType) {
60901
+ if (!node.selectionSet || node.selectionSet.selections.length == 0) {
60902
+ return;
60903
+ }
60904
+ if (!graphql23.isObjectType(fieldType) && !graphql23.isInterfaceType(fieldType)) {
60905
+ return;
60906
+ }
60907
+ const keyFields = config2.keyFieldsForType(fieldType.name);
60908
+ if (keyFields.find((key) => !fieldType.getFields()[key])) {
60909
+ return;
60910
+ }
60911
+ const selections = [...node.selectionSet.selections];
60912
+ for (const keyField of keyFields) {
60913
+ if (node.selectionSet.selections.find(
60914
+ (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
60915
+ )) {
60916
+ continue;
60917
+ }
60918
+ selections.push({
60919
+ kind: graphql23.Kind.FIELD,
60920
+ name: {
60921
+ kind: graphql23.Kind.NAME,
60922
+ value: keyField
60910
60923
  }
60911
60924
  });
60912
60925
  }
60926
+ return {
60927
+ ...node,
60928
+ selectionSet: {
60929
+ ...node.selectionSet,
60930
+ selections
60931
+ }
60932
+ };
60913
60933
  }
60914
60934
 
60915
60935
  // src/codegen/validators/typeCheck.ts
@@ -60035,6 +60035,12 @@ function inlineType({
60035
60035
  includeFragments,
60036
60036
  allOptional
60037
60037
  });
60038
+ const hasIncludeOrSkipDirective = selection2.directives && selection2.directives.filter(
60039
+ (directive) => directive.name.value === "include" || directive.name.value === "skip"
60040
+ ).length > 0;
60041
+ if (hasIncludeOrSkipDirective) {
60042
+ attributeType = AST10.tsUnionType([attributeType, AST10.tsUndefinedKeyword()]);
60043
+ }
60038
60044
  const prop = readonlyProperty(
60039
60045
  AST10.tsPropertySignature(
60040
60046
  AST10.identifier(attributeName),
@@ -61199,40 +61205,54 @@ async function addID(config2, documents) {
61199
61205
  );
61200
61206
  const field = type.getFields()[node.name.value];
61201
61207
  const fieldType = unwrapType(config2, field.type).type;
61202
- if (node.selectionSet?.selections.length > 0) {
61203
- if (!graphql22.isObjectType(fieldType) && !graphql22.isInterfaceType(fieldType)) {
61204
- return;
61205
- }
61206
- const keyFields = config2.keyFieldsForType(fieldType.name);
61207
- if (keyFields.find((key2) => !fieldType.getFields()[key2])) {
61208
- return;
61209
- }
61210
- const selections = [...node.selectionSet.selections];
61211
- for (const keyField of keyFields) {
61212
- if (node.selectionSet.selections.find(
61213
- (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
61214
- )) {
61215
- continue;
61216
- }
61217
- selections.push({
61218
- kind: graphql22.Kind.FIELD,
61219
- name: {
61220
- kind: graphql22.Kind.NAME,
61221
- value: keyField
61222
- }
61223
- });
61224
- }
61225
- return {
61226
- ...node,
61227
- selectionSet: {
61228
- ...node.selectionSet,
61229
- selections
61230
- }
61231
- };
61208
+ return addKeysToSelection(config2, node, fieldType);
61209
+ },
61210
+ InlineFragment(node) {
61211
+ if (!node.selectionSet || !node.typeCondition) {
61212
+ return;
61232
61213
  }
61214
+ const fragmentType = config2.schema.getType(node.typeCondition.name.value);
61215
+ if (!fragmentType) {
61216
+ return;
61217
+ }
61218
+ return addKeysToSelection(config2, node, fragmentType);
61219
+ }
61220
+ });
61221
+ }
61222
+ }
61223
+ function addKeysToSelection(config2, node, fieldType) {
61224
+ if (!node.selectionSet || node.selectionSet.selections.length == 0) {
61225
+ return;
61226
+ }
61227
+ if (!graphql22.isObjectType(fieldType) && !graphql22.isInterfaceType(fieldType)) {
61228
+ return;
61229
+ }
61230
+ const keyFields = config2.keyFieldsForType(fieldType.name);
61231
+ if (keyFields.find((key) => !fieldType.getFields()[key])) {
61232
+ return;
61233
+ }
61234
+ const selections = [...node.selectionSet.selections];
61235
+ for (const keyField of keyFields) {
61236
+ if (node.selectionSet.selections.find(
61237
+ (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
61238
+ )) {
61239
+ continue;
61240
+ }
61241
+ selections.push({
61242
+ kind: graphql22.Kind.FIELD,
61243
+ name: {
61244
+ kind: graphql22.Kind.NAME,
61245
+ value: keyField
61233
61246
  }
61234
61247
  });
61235
61248
  }
61249
+ return {
61250
+ ...node,
61251
+ selectionSet: {
61252
+ ...node.selectionSet,
61253
+ selections
61254
+ }
61255
+ };
61236
61256
  }
61237
61257
 
61238
61258
  // src/codegen/validators/typeCheck.ts
@@ -60030,6 +60030,12 @@ function inlineType({
60030
60030
  includeFragments,
60031
60031
  allOptional
60032
60032
  });
60033
+ const hasIncludeOrSkipDirective = selection2.directives && selection2.directives.filter(
60034
+ (directive) => directive.name.value === "include" || directive.name.value === "skip"
60035
+ ).length > 0;
60036
+ if (hasIncludeOrSkipDirective) {
60037
+ attributeType = AST10.tsUnionType([attributeType, AST10.tsUndefinedKeyword()]);
60038
+ }
60033
60039
  const prop = readonlyProperty(
60034
60040
  AST10.tsPropertySignature(
60035
60041
  AST10.identifier(attributeName),
@@ -61194,40 +61200,54 @@ async function addID(config2, documents) {
61194
61200
  );
61195
61201
  const field = type.getFields()[node.name.value];
61196
61202
  const fieldType = unwrapType(config2, field.type).type;
61197
- if (node.selectionSet?.selections.length > 0) {
61198
- if (!graphql22.isObjectType(fieldType) && !graphql22.isInterfaceType(fieldType)) {
61199
- return;
61200
- }
61201
- const keyFields = config2.keyFieldsForType(fieldType.name);
61202
- if (keyFields.find((key2) => !fieldType.getFields()[key2])) {
61203
- return;
61204
- }
61205
- const selections = [...node.selectionSet.selections];
61206
- for (const keyField of keyFields) {
61207
- if (node.selectionSet.selections.find(
61208
- (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
61209
- )) {
61210
- continue;
61211
- }
61212
- selections.push({
61213
- kind: graphql22.Kind.FIELD,
61214
- name: {
61215
- kind: graphql22.Kind.NAME,
61216
- value: keyField
61217
- }
61218
- });
61219
- }
61220
- return {
61221
- ...node,
61222
- selectionSet: {
61223
- ...node.selectionSet,
61224
- selections
61225
- }
61226
- };
61203
+ return addKeysToSelection(config2, node, fieldType);
61204
+ },
61205
+ InlineFragment(node) {
61206
+ if (!node.selectionSet || !node.typeCondition) {
61207
+ return;
61227
61208
  }
61209
+ const fragmentType = config2.schema.getType(node.typeCondition.name.value);
61210
+ if (!fragmentType) {
61211
+ return;
61212
+ }
61213
+ return addKeysToSelection(config2, node, fragmentType);
61214
+ }
61215
+ });
61216
+ }
61217
+ }
61218
+ function addKeysToSelection(config2, node, fieldType) {
61219
+ if (!node.selectionSet || node.selectionSet.selections.length == 0) {
61220
+ return;
61221
+ }
61222
+ if (!graphql22.isObjectType(fieldType) && !graphql22.isInterfaceType(fieldType)) {
61223
+ return;
61224
+ }
61225
+ const keyFields = config2.keyFieldsForType(fieldType.name);
61226
+ if (keyFields.find((key) => !fieldType.getFields()[key])) {
61227
+ return;
61228
+ }
61229
+ const selections = [...node.selectionSet.selections];
61230
+ for (const keyField of keyFields) {
61231
+ if (node.selectionSet.selections.find(
61232
+ (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
61233
+ )) {
61234
+ continue;
61235
+ }
61236
+ selections.push({
61237
+ kind: graphql22.Kind.FIELD,
61238
+ name: {
61239
+ kind: graphql22.Kind.NAME,
61240
+ value: keyField
61228
61241
  }
61229
61242
  });
61230
61243
  }
61244
+ return {
61245
+ ...node,
61246
+ selectionSet: {
61247
+ ...node.selectionSet,
61248
+ selections
61249
+ }
61250
+ };
61231
61251
  }
61232
61252
 
61233
61253
  // src/codegen/validators/typeCheck.ts
@@ -72825,6 +72825,12 @@ function inlineType({
72825
72825
  includeFragments,
72826
72826
  allOptional
72827
72827
  });
72828
+ const hasIncludeOrSkipDirective = selection2.directives && selection2.directives.filter(
72829
+ (directive) => directive.name.value === "include" || directive.name.value === "skip"
72830
+ ).length > 0;
72831
+ if (hasIncludeOrSkipDirective) {
72832
+ attributeType = AST10.tsUnionType([attributeType, AST10.tsUndefinedKeyword()]);
72833
+ }
72828
72834
  const prop = readonlyProperty(
72829
72835
  AST10.tsPropertySignature(
72830
72836
  AST10.identifier(attributeName),
@@ -73989,40 +73995,54 @@ async function addID(config4, documents) {
73989
73995
  );
73990
73996
  const field = type.getFields()[node.name.value];
73991
73997
  const fieldType = unwrapType(config4, field.type).type;
73992
- if (node.selectionSet?.selections.length > 0) {
73993
- if (!graphql24.isObjectType(fieldType) && !graphql24.isInterfaceType(fieldType)) {
73994
- return;
73995
- }
73996
- const keyFields = config4.keyFieldsForType(fieldType.name);
73997
- if (keyFields.find((key2) => !fieldType.getFields()[key2])) {
73998
- return;
73999
- }
74000
- const selections = [...node.selectionSet.selections];
74001
- for (const keyField of keyFields) {
74002
- if (node.selectionSet.selections.find(
74003
- (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
74004
- )) {
74005
- continue;
74006
- }
74007
- selections.push({
74008
- kind: graphql24.Kind.FIELD,
74009
- name: {
74010
- kind: graphql24.Kind.NAME,
74011
- value: keyField
74012
- }
74013
- });
74014
- }
74015
- return {
74016
- ...node,
74017
- selectionSet: {
74018
- ...node.selectionSet,
74019
- selections
74020
- }
74021
- };
73998
+ return addKeysToSelection(config4, node, fieldType);
73999
+ },
74000
+ InlineFragment(node) {
74001
+ if (!node.selectionSet || !node.typeCondition) {
74002
+ return;
74022
74003
  }
74004
+ const fragmentType = config4.schema.getType(node.typeCondition.name.value);
74005
+ if (!fragmentType) {
74006
+ return;
74007
+ }
74008
+ return addKeysToSelection(config4, node, fragmentType);
74009
+ }
74010
+ });
74011
+ }
74012
+ }
74013
+ function addKeysToSelection(config4, node, fieldType) {
74014
+ if (!node.selectionSet || node.selectionSet.selections.length == 0) {
74015
+ return;
74016
+ }
74017
+ if (!graphql24.isObjectType(fieldType) && !graphql24.isInterfaceType(fieldType)) {
74018
+ return;
74019
+ }
74020
+ const keyFields = config4.keyFieldsForType(fieldType.name);
74021
+ if (keyFields.find((key) => !fieldType.getFields()[key])) {
74022
+ return;
74023
+ }
74024
+ const selections = [...node.selectionSet.selections];
74025
+ for (const keyField of keyFields) {
74026
+ if (node.selectionSet.selections.find(
74027
+ (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
74028
+ )) {
74029
+ continue;
74030
+ }
74031
+ selections.push({
74032
+ kind: graphql24.Kind.FIELD,
74033
+ name: {
74034
+ kind: graphql24.Kind.NAME,
74035
+ value: keyField
74023
74036
  }
74024
74037
  });
74025
74038
  }
74039
+ return {
74040
+ ...node,
74041
+ selectionSet: {
74042
+ ...node.selectionSet,
74043
+ selections
74044
+ }
74045
+ };
74026
74046
  }
74027
74047
 
74028
74048
  // src/codegen/validators/typeCheck.ts
@@ -72819,6 +72819,12 @@ function inlineType({
72819
72819
  includeFragments,
72820
72820
  allOptional
72821
72821
  });
72822
+ const hasIncludeOrSkipDirective = selection2.directives && selection2.directives.filter(
72823
+ (directive) => directive.name.value === "include" || directive.name.value === "skip"
72824
+ ).length > 0;
72825
+ if (hasIncludeOrSkipDirective) {
72826
+ attributeType = AST10.tsUnionType([attributeType, AST10.tsUndefinedKeyword()]);
72827
+ }
72822
72828
  const prop = readonlyProperty(
72823
72829
  AST10.tsPropertySignature(
72824
72830
  AST10.identifier(attributeName),
@@ -73983,40 +73989,54 @@ async function addID(config4, documents) {
73983
73989
  );
73984
73990
  const field = type.getFields()[node.name.value];
73985
73991
  const fieldType = unwrapType(config4, field.type).type;
73986
- if (node.selectionSet?.selections.length > 0) {
73987
- if (!graphql24.isObjectType(fieldType) && !graphql24.isInterfaceType(fieldType)) {
73988
- return;
73989
- }
73990
- const keyFields = config4.keyFieldsForType(fieldType.name);
73991
- if (keyFields.find((key2) => !fieldType.getFields()[key2])) {
73992
- return;
73993
- }
73994
- const selections = [...node.selectionSet.selections];
73995
- for (const keyField of keyFields) {
73996
- if (node.selectionSet.selections.find(
73997
- (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
73998
- )) {
73999
- continue;
74000
- }
74001
- selections.push({
74002
- kind: graphql24.Kind.FIELD,
74003
- name: {
74004
- kind: graphql24.Kind.NAME,
74005
- value: keyField
74006
- }
74007
- });
74008
- }
74009
- return {
74010
- ...node,
74011
- selectionSet: {
74012
- ...node.selectionSet,
74013
- selections
74014
- }
74015
- };
73992
+ return addKeysToSelection(config4, node, fieldType);
73993
+ },
73994
+ InlineFragment(node) {
73995
+ if (!node.selectionSet || !node.typeCondition) {
73996
+ return;
74016
73997
  }
73998
+ const fragmentType = config4.schema.getType(node.typeCondition.name.value);
73999
+ if (!fragmentType) {
74000
+ return;
74001
+ }
74002
+ return addKeysToSelection(config4, node, fragmentType);
74003
+ }
74004
+ });
74005
+ }
74006
+ }
74007
+ function addKeysToSelection(config4, node, fieldType) {
74008
+ if (!node.selectionSet || node.selectionSet.selections.length == 0) {
74009
+ return;
74010
+ }
74011
+ if (!graphql24.isObjectType(fieldType) && !graphql24.isInterfaceType(fieldType)) {
74012
+ return;
74013
+ }
74014
+ const keyFields = config4.keyFieldsForType(fieldType.name);
74015
+ if (keyFields.find((key) => !fieldType.getFields()[key])) {
74016
+ return;
74017
+ }
74018
+ const selections = [...node.selectionSet.selections];
74019
+ for (const keyField of keyFields) {
74020
+ if (node.selectionSet.selections.find(
74021
+ (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
74022
+ )) {
74023
+ continue;
74024
+ }
74025
+ selections.push({
74026
+ kind: graphql24.Kind.FIELD,
74027
+ name: {
74028
+ kind: graphql24.Kind.NAME,
74029
+ value: keyField
74017
74030
  }
74018
74031
  });
74019
74032
  }
74033
+ return {
74034
+ ...node,
74035
+ selectionSet: {
74036
+ ...node.selectionSet,
74037
+ selections
74038
+ }
74039
+ };
74020
74040
  }
74021
74041
 
74022
74042
  // src/codegen/validators/typeCheck.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",