houdini 1.0.11 → 1.1.1-next.0

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 (67) hide show
  1. package/build/cmd-cjs/index.js +659 -330
  2. package/build/cmd-esm/index.js +659 -330
  3. package/build/codegen/generators/artifacts/selection.d.ts +5 -2
  4. package/build/codegen/generators/typescript/inlineType.d.ts +1 -1
  5. package/build/codegen/transforms/{composeQueries.d.ts → collectDefinitions.d.ts} +1 -1
  6. package/build/codegen/transforms/fragmentVariables.d.ts +2 -4
  7. package/build/codegen/transforms/index.d.ts +1 -1
  8. package/build/codegen/utils/flattenSelections.d.ts +2 -2
  9. package/build/codegen-cjs/index.js +604 -326
  10. package/build/codegen-esm/index.js +604 -326
  11. package/build/lib/config.d.ts +10 -1
  12. package/build/lib/deepMerge.d.ts +1 -1
  13. package/build/lib/types.d.ts +1 -0
  14. package/build/lib-cjs/index.js +261 -115
  15. package/build/lib-esm/index.js +260 -115
  16. package/build/runtime/cache/cache.d.ts +17 -6
  17. package/build/runtime/client/documentStore.d.ts +1 -0
  18. package/build/runtime/client/plugins/cache.d.ts +3 -2
  19. package/build/runtime/client/plugins/fragment.d.ts +2 -0
  20. package/build/runtime/client/plugins/index.d.ts +1 -0
  21. package/build/runtime/lib/scalars.d.ts +0 -1
  22. package/build/runtime/lib/types.d.ts +55 -7
  23. package/build/runtime-cjs/cache/cache.d.ts +17 -6
  24. package/build/runtime-cjs/cache/cache.js +89 -21
  25. package/build/runtime-cjs/cache/lists.js +2 -1
  26. package/build/runtime-cjs/cache/subscription.js +11 -2
  27. package/build/runtime-cjs/client/documentStore.d.ts +1 -0
  28. package/build/runtime-cjs/client/documentStore.js +5 -14
  29. package/build/runtime-cjs/client/index.js +2 -1
  30. package/build/runtime-cjs/client/plugins/cache.d.ts +3 -2
  31. package/build/runtime-cjs/client/plugins/cache.js +19 -3
  32. package/build/runtime-cjs/client/plugins/fetch.js +4 -1
  33. package/build/runtime-cjs/client/plugins/fragment.d.ts +2 -0
  34. package/build/runtime-cjs/client/plugins/fragment.js +76 -0
  35. package/build/runtime-cjs/client/plugins/index.d.ts +1 -0
  36. package/build/runtime-cjs/client/plugins/index.js +1 -0
  37. package/build/runtime-cjs/client/plugins/query.js +3 -5
  38. package/build/runtime-cjs/lib/scalars.d.ts +0 -1
  39. package/build/runtime-cjs/lib/scalars.js +2 -43
  40. package/build/runtime-cjs/lib/types.d.ts +55 -7
  41. package/build/runtime-cjs/lib/types.js +5 -2
  42. package/build/runtime-cjs/public/tests/test.js +4 -2
  43. package/build/runtime-esm/cache/cache.d.ts +17 -6
  44. package/build/runtime-esm/cache/cache.js +89 -22
  45. package/build/runtime-esm/cache/lists.js +2 -1
  46. package/build/runtime-esm/cache/subscription.js +11 -2
  47. package/build/runtime-esm/client/documentStore.d.ts +1 -0
  48. package/build/runtime-esm/client/documentStore.js +6 -15
  49. package/build/runtime-esm/client/index.js +3 -1
  50. package/build/runtime-esm/client/plugins/cache.d.ts +3 -2
  51. package/build/runtime-esm/client/plugins/cache.js +19 -3
  52. package/build/runtime-esm/client/plugins/fetch.js +5 -2
  53. package/build/runtime-esm/client/plugins/fragment.d.ts +2 -0
  54. package/build/runtime-esm/client/plugins/fragment.js +46 -0
  55. package/build/runtime-esm/client/plugins/index.d.ts +1 -0
  56. package/build/runtime-esm/client/plugins/index.js +1 -0
  57. package/build/runtime-esm/client/plugins/query.js +3 -5
  58. package/build/runtime-esm/lib/scalars.d.ts +0 -1
  59. package/build/runtime-esm/lib/scalars.js +1 -41
  60. package/build/runtime-esm/lib/types.d.ts +55 -7
  61. package/build/runtime-esm/lib/types.js +3 -1
  62. package/build/runtime-esm/public/tests/test.js +4 -2
  63. package/build/test-cjs/index.js +658 -329
  64. package/build/test-esm/index.js +658 -329
  65. package/build/vite-cjs/index.js +657 -328
  66. package/build/vite-esm/index.js +657 -328
  67. package/package.json +2 -2
@@ -7516,7 +7516,7 @@ var require_definition = __commonJS({
7516
7516
  exports.assertLeafType = assertLeafType;
7517
7517
  exports.isCompositeType = isCompositeType;
7518
7518
  exports.assertCompositeType = assertCompositeType;
7519
- exports.isAbstractType = isAbstractType3;
7519
+ exports.isAbstractType = isAbstractType4;
7520
7520
  exports.assertAbstractType = assertAbstractType;
7521
7521
  exports.GraphQLList = GraphQLList6;
7522
7522
  exports.GraphQLNonNull = GraphQLNonNull6;
@@ -7687,11 +7687,11 @@ var require_definition = __commonJS({
7687
7687
  }
7688
7688
  return type;
7689
7689
  }
7690
- function isAbstractType3(type) {
7690
+ function isAbstractType4(type) {
7691
7691
  return isInterfaceType12(type) || isUnionType13(type);
7692
7692
  }
7693
7693
  function assertAbstractType(type) {
7694
- if (!isAbstractType3(type)) {
7694
+ if (!isAbstractType4(type)) {
7695
7695
  throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL abstract type."));
7696
7696
  }
7697
7697
  return type;
@@ -10955,8 +10955,8 @@ var require_KnownFragmentNamesRule = __commonJS({
10955
10955
  return {
10956
10956
  FragmentSpread: function FragmentSpread(node) {
10957
10957
  var fragmentName = node.name.value;
10958
- var fragment = context.getFragment(fragmentName);
10959
- if (!fragment) {
10958
+ var fragment2 = context.getFragment(fragmentName);
10959
+ if (!fragment2) {
10960
10960
  context.reportError(new _GraphQLError.GraphQLError('Unknown fragment "'.concat(fragmentName, '".'), node.name));
10961
10961
  }
10962
10962
  }
@@ -10992,8 +10992,8 @@ var require_NoUnusedFragmentsRule = __commonJS({
10992
10992
  for (var _i2 = 0; _i2 < operationDefs.length; _i2++) {
10993
10993
  var operation = operationDefs[_i2];
10994
10994
  for (var _i4 = 0, _context$getRecursive2 = context.getRecursivelyReferencedFragments(operation); _i4 < _context$getRecursive2.length; _i4++) {
10995
- var fragment = _context$getRecursive2[_i4];
10996
- fragmentNameUsed[fragment.name.value] = true;
10995
+ var fragment2 = _context$getRecursive2[_i4];
10996
+ fragmentNameUsed[fragment2.name.value] = true;
10997
10997
  }
10998
10998
  }
10999
10999
  for (var _i6 = 0; _i6 < fragmentDefs.length; _i6++) {
@@ -11083,13 +11083,13 @@ var require_NoFragmentCyclesRule = __commonJS({
11083
11083
  return false;
11084
11084
  }
11085
11085
  };
11086
- function detectCycleRecursive(fragment) {
11087
- if (visitedFrags[fragment.name.value]) {
11086
+ function detectCycleRecursive(fragment2) {
11087
+ if (visitedFrags[fragment2.name.value]) {
11088
11088
  return;
11089
11089
  }
11090
- var fragmentName = fragment.name.value;
11090
+ var fragmentName = fragment2.name.value;
11091
11091
  visitedFrags[fragmentName] = true;
11092
- var spreadNodes = context.getFragmentSpreads(fragment.selectionSet);
11092
+ var spreadNodes = context.getFragmentSpreads(fragment2.selectionSet);
11093
11093
  if (spreadNodes.length === 0) {
11094
11094
  return;
11095
11095
  }
@@ -11910,11 +11910,11 @@ var require_OverlappingFieldsCanBeMergedRule = __commonJS({
11910
11910
  return conflicts;
11911
11911
  }
11912
11912
  function collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fragmentName) {
11913
- var fragment = context.getFragment(fragmentName);
11914
- if (!fragment) {
11913
+ var fragment2 = context.getFragment(fragmentName);
11914
+ if (!fragment2) {
11915
11915
  return;
11916
11916
  }
11917
- var _getReferencedFieldsA = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment), fieldMap2 = _getReferencedFieldsA[0], fragmentNames2 = _getReferencedFieldsA[1];
11917
+ var _getReferencedFieldsA = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2), fieldMap2 = _getReferencedFieldsA[0], fragmentNames2 = _getReferencedFieldsA[1];
11918
11918
  if (fieldMap === fieldMap2) {
11919
11919
  return;
11920
11920
  }
@@ -12085,38 +12085,38 @@ var require_OverlappingFieldsCanBeMergedRule = __commonJS({
12085
12085
  }
12086
12086
  return cached;
12087
12087
  }
12088
- function getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment) {
12089
- var cached = cachedFieldsAndFragmentNames.get(fragment.selectionSet);
12088
+ function getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2) {
12089
+ var cached = cachedFieldsAndFragmentNames.get(fragment2.selectionSet);
12090
12090
  if (cached) {
12091
12091
  return cached;
12092
12092
  }
12093
- var fragmentType = (0, _typeFromAST.typeFromAST)(context.getSchema(), fragment.typeCondition);
12094
- return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType, fragment.selectionSet);
12093
+ var fragmentType = (0, _typeFromAST.typeFromAST)(context.getSchema(), fragment2.typeCondition);
12094
+ return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType, fragment2.selectionSet);
12095
12095
  }
12096
12096
  function _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames) {
12097
12097
  for (var _i9 = 0, _selectionSet$selecti2 = selectionSet.selections; _i9 < _selectionSet$selecti2.length; _i9++) {
12098
- var selection2 = _selectionSet$selecti2[_i9];
12099
- switch (selection2.kind) {
12098
+ var selection = _selectionSet$selecti2[_i9];
12099
+ switch (selection.kind) {
12100
12100
  case _kinds.Kind.FIELD: {
12101
- var fieldName = selection2.name.value;
12101
+ var fieldName = selection.name.value;
12102
12102
  var fieldDef = void 0;
12103
12103
  if ((0, _definition.isObjectType)(parentType) || (0, _definition.isInterfaceType)(parentType)) {
12104
12104
  fieldDef = parentType.getFields()[fieldName];
12105
12105
  }
12106
- var responseName = selection2.alias ? selection2.alias.value : fieldName;
12106
+ var responseName = selection.alias ? selection.alias.value : fieldName;
12107
12107
  if (!nodeAndDefs[responseName]) {
12108
12108
  nodeAndDefs[responseName] = [];
12109
12109
  }
12110
- nodeAndDefs[responseName].push([parentType, selection2, fieldDef]);
12110
+ nodeAndDefs[responseName].push([parentType, selection, fieldDef]);
12111
12111
  break;
12112
12112
  }
12113
12113
  case _kinds.Kind.FRAGMENT_SPREAD:
12114
- fragmentNames[selection2.name.value] = true;
12114
+ fragmentNames[selection.name.value] = true;
12115
12115
  break;
12116
12116
  case _kinds.Kind.INLINE_FRAGMENT: {
12117
- var typeCondition = selection2.typeCondition;
12117
+ var typeCondition = selection.typeCondition;
12118
12118
  var inlineFragmentType = typeCondition ? (0, _typeFromAST.typeFromAST)(context.getSchema(), typeCondition) : parentType;
12119
- _collectFieldsAndFragmentNames(context, inlineFragmentType, selection2.selectionSet, nodeAndDefs, fragmentNames);
12119
+ _collectFieldsAndFragmentNames(context, inlineFragmentType, selection.selectionSet, nodeAndDefs, fragmentNames);
12120
12120
  break;
12121
12121
  }
12122
12122
  }
@@ -12652,11 +12652,11 @@ var require_ValidationContext = __commonJS({
12652
12652
  while (setsToVisit.length !== 0) {
12653
12653
  var set = setsToVisit.pop();
12654
12654
  for (var _i2 = 0, _set$selections2 = set.selections; _i2 < _set$selections2.length; _i2++) {
12655
- var selection2 = _set$selections2[_i2];
12656
- if (selection2.kind === _kinds.Kind.FRAGMENT_SPREAD) {
12657
- spreads.push(selection2);
12658
- } else if (selection2.selectionSet) {
12659
- setsToVisit.push(selection2.selectionSet);
12655
+ var selection = _set$selections2[_i2];
12656
+ if (selection.kind === _kinds.Kind.FRAGMENT_SPREAD) {
12657
+ spreads.push(selection);
12658
+ } else if (selection.selectionSet) {
12659
+ setsToVisit.push(selection.selectionSet);
12660
12660
  }
12661
12661
  }
12662
12662
  }
@@ -12677,10 +12677,10 @@ var require_ValidationContext = __commonJS({
12677
12677
  var fragName = spread.name.value;
12678
12678
  if (collectedNames[fragName] !== true) {
12679
12679
  collectedNames[fragName] = true;
12680
- var fragment = this.getFragment(fragName);
12681
- if (fragment) {
12682
- fragments.push(fragment);
12683
- nodesToVisit.push(fragment.selectionSet);
12680
+ var fragment2 = this.getFragment(fragName);
12681
+ if (fragment2) {
12682
+ fragments.push(fragment2);
12683
+ nodesToVisit.push(fragment2.selectionSet);
12684
12684
  }
12685
12685
  }
12686
12686
  }
@@ -13593,37 +13593,37 @@ var require_execute = __commonJS({
13593
13593
  }
13594
13594
  function collectFields(exeContext, runtimeType, selectionSet, fields, visitedFragmentNames) {
13595
13595
  for (var _i6 = 0, _selectionSet$selecti2 = selectionSet.selections; _i6 < _selectionSet$selecti2.length; _i6++) {
13596
- var selection2 = _selectionSet$selecti2[_i6];
13597
- switch (selection2.kind) {
13596
+ var selection = _selectionSet$selecti2[_i6];
13597
+ switch (selection.kind) {
13598
13598
  case _kinds.Kind.FIELD: {
13599
- if (!shouldIncludeNode(exeContext, selection2)) {
13599
+ if (!shouldIncludeNode(exeContext, selection)) {
13600
13600
  continue;
13601
13601
  }
13602
- var name = getFieldEntryKey(selection2);
13602
+ var name = getFieldEntryKey(selection);
13603
13603
  if (!fields[name]) {
13604
13604
  fields[name] = [];
13605
13605
  }
13606
- fields[name].push(selection2);
13606
+ fields[name].push(selection);
13607
13607
  break;
13608
13608
  }
13609
13609
  case _kinds.Kind.INLINE_FRAGMENT: {
13610
- if (!shouldIncludeNode(exeContext, selection2) || !doesFragmentConditionMatch(exeContext, selection2, runtimeType)) {
13610
+ if (!shouldIncludeNode(exeContext, selection) || !doesFragmentConditionMatch(exeContext, selection, runtimeType)) {
13611
13611
  continue;
13612
13612
  }
13613
- collectFields(exeContext, runtimeType, selection2.selectionSet, fields, visitedFragmentNames);
13613
+ collectFields(exeContext, runtimeType, selection.selectionSet, fields, visitedFragmentNames);
13614
13614
  break;
13615
13615
  }
13616
13616
  case _kinds.Kind.FRAGMENT_SPREAD: {
13617
- var fragName = selection2.name.value;
13618
- if (visitedFragmentNames[fragName] || !shouldIncludeNode(exeContext, selection2)) {
13617
+ var fragName = selection.name.value;
13618
+ if (visitedFragmentNames[fragName] || !shouldIncludeNode(exeContext, selection)) {
13619
13619
  continue;
13620
13620
  }
13621
13621
  visitedFragmentNames[fragName] = true;
13622
- var fragment = exeContext.fragments[fragName];
13623
- if (!fragment || !doesFragmentConditionMatch(exeContext, fragment, runtimeType)) {
13622
+ var fragment2 = exeContext.fragments[fragName];
13623
+ if (!fragment2 || !doesFragmentConditionMatch(exeContext, fragment2, runtimeType)) {
13624
13624
  continue;
13625
13625
  }
13626
- collectFields(exeContext, runtimeType, fragment.selectionSet, fields, visitedFragmentNames);
13626
+ collectFields(exeContext, runtimeType, fragment2.selectionSet, fields, visitedFragmentNames);
13627
13627
  break;
13628
13628
  }
13629
13629
  }
@@ -13641,8 +13641,8 @@ var require_execute = __commonJS({
13641
13641
  }
13642
13642
  return true;
13643
13643
  }
13644
- function doesFragmentConditionMatch(exeContext, fragment, type) {
13645
- var typeConditionNode = fragment.typeCondition;
13644
+ function doesFragmentConditionMatch(exeContext, fragment2, type) {
13645
+ var typeConditionNode = fragment2.typeCondition;
13646
13646
  if (!typeConditionNode) {
13647
13647
  return true;
13648
13648
  }
@@ -65335,14 +65335,14 @@ function deepEquals(objA, objB, map = /* @__PURE__ */ new WeakMap()) {
65335
65335
  }
65336
65336
 
65337
65337
  // src/runtime/lib/selection.ts
65338
- function getFieldsForType(selection2, __typename) {
65339
- let targetSelection = selection2.fields || {};
65340
- if (selection2.abstractFields && __typename) {
65341
- const mappedType = selection2.abstractFields.typeMap[__typename];
65338
+ function getFieldsForType(selection, __typename) {
65339
+ let targetSelection = selection.fields || {};
65340
+ if (selection.abstractFields && __typename) {
65341
+ const mappedType = selection.abstractFields.typeMap[__typename];
65342
65342
  if (mappedType) {
65343
- targetSelection = selection2.abstractFields.fields[mappedType];
65344
- } else if (selection2.abstractFields.fields[__typename]) {
65345
- targetSelection = selection2.abstractFields.fields[__typename];
65343
+ targetSelection = selection.abstractFields.fields[mappedType];
65344
+ } else if (selection.abstractFields.fields[__typename]) {
65345
+ targetSelection = selection.abstractFields.fields[__typename];
65346
65346
  }
65347
65347
  }
65348
65348
  return targetSelection;
@@ -65350,7 +65350,7 @@ function getFieldsForType(selection2, __typename) {
65350
65350
 
65351
65351
  // src/runtime/lib/scalars.ts
65352
65352
  async function marshalSelection({
65353
- selection: selection2,
65353
+ selection,
65354
65354
  data
65355
65355
  }) {
65356
65356
  const config4 = getCurrentConfig();
@@ -65358,18 +65358,18 @@ async function marshalSelection({
65358
65358
  return data;
65359
65359
  }
65360
65360
  if (Array.isArray(data)) {
65361
- return await Promise.all(data.map((val) => marshalSelection({ selection: selection2, data: val })));
65361
+ return await Promise.all(data.map((val) => marshalSelection({ selection, data: val })));
65362
65362
  }
65363
- const targetSelection = getFieldsForType(selection2, data["__typename"]);
65363
+ const targetSelection = getFieldsForType(selection, data["__typename"]);
65364
65364
  return Object.fromEntries(
65365
65365
  await Promise.all(
65366
65366
  Object.entries(data).map(async ([fieldName, value]) => {
65367
- const { type, selection: selection3 } = targetSelection[fieldName];
65367
+ const { type, selection: selection2 } = targetSelection[fieldName];
65368
65368
  if (!type) {
65369
65369
  return [fieldName, value];
65370
65370
  }
65371
- if (selection3) {
65372
- return [fieldName, await marshalSelection({ selection: selection3, data: value })];
65371
+ if (selection2) {
65372
+ return [fieldName, await marshalSelection({ selection: selection2, data: value })];
65373
65373
  }
65374
65374
  if (config4.scalars?.[type]) {
65375
65375
  const marshalFn = config4.scalars[type].marshal;
@@ -65420,6 +65420,7 @@ var DataSource = {
65420
65420
  Network: "network",
65421
65421
  Ssr: "ssr"
65422
65422
  };
65423
+ var fragmentKey = " $fragments";
65423
65424
 
65424
65425
  // src/runtime/lib/key.ts
65425
65426
  var computeKey = ({ field, args }) => {
@@ -67162,7 +67163,7 @@ var List = class {
67162
67163
  recordType,
67163
67164
  key,
67164
67165
  listType,
67165
- selection: selection2,
67166
+ selection,
67166
67167
  when,
67167
67168
  filters,
67168
67169
  connection,
@@ -67174,7 +67175,7 @@ var List = class {
67174
67175
  this.key = key;
67175
67176
  this.type = listType;
67176
67177
  this.cache = manager.cache;
67177
- this.selection = selection2;
67178
+ this.selection = selection;
67178
67179
  this._when = when;
67179
67180
  this.filters = filters;
67180
67181
  this.name = name;
@@ -67185,19 +67186,19 @@ var List = class {
67185
67186
  when(when) {
67186
67187
  return this.manager.lists.get(this.name).get(this.recordID).when(when);
67187
67188
  }
67188
- append(selection2, data, variables = {}) {
67189
- return this.addToList(selection2, data, variables, "last");
67189
+ append(selection, data, variables = {}) {
67190
+ return this.addToList(selection, data, variables, "last");
67190
67191
  }
67191
- prepend(selection2, data, variables = {}) {
67192
- return this.addToList(selection2, data, variables, "first");
67192
+ prepend(selection, data, variables = {}) {
67193
+ return this.addToList(selection, data, variables, "first");
67193
67194
  }
67194
- addToList(selection2, data, variables = {}, where) {
67195
+ addToList(selection, data, variables = {}, where) {
67195
67196
  const listType = this.listType(data);
67196
67197
  const dataID = this.cache._internal_unstable.id(listType, data);
67197
67198
  if (!this.validateWhen() || !dataID) {
67198
67199
  return;
67199
67200
  }
67200
- let insertSelection = selection2;
67201
+ let insertSelection = selection;
67201
67202
  let insertData = data;
67202
67203
  if (this.connection) {
67203
67204
  insertSelection = {
@@ -67217,9 +67218,9 @@ var List = class {
67217
67218
  type: listType,
67218
67219
  keyRaw: "node",
67219
67220
  selection: {
67220
- ...selection2,
67221
+ ...selection,
67221
67222
  fields: {
67222
- ...selection2.fields,
67223
+ ...selection.fields,
67223
67224
  __typename: {
67224
67225
  keyRaw: "__typename",
67225
67226
  type: "String"
@@ -67248,9 +67249,9 @@ var List = class {
67248
67249
  type: listType,
67249
67250
  updates: ["append", "prepend"],
67250
67251
  selection: {
67251
- ...selection2,
67252
+ ...selection,
67252
67253
  fields: {
67253
- ...selection2.fields,
67254
+ ...selection.fields,
67254
67255
  __typename: {
67255
67256
  keyRaw: "__typename",
67256
67257
  type: "String"
@@ -67325,7 +67326,8 @@ var List = class {
67325
67326
  this.cache._internal_unstable.getSelection({
67326
67327
  parent: spec.parentID || this.manager.rootID,
67327
67328
  selection: spec.selection,
67328
- variables: spec.variables?.() || {}
67329
+ variables: spec.variables?.() || {},
67330
+ ignoreMasking: false
67329
67331
  }).data
67330
67332
  );
67331
67333
  }
@@ -67361,9 +67363,9 @@ var List = class {
67361
67363
  }
67362
67364
  return ok;
67363
67365
  }
67364
- toggleElement(selection2, data, variables = {}, where) {
67366
+ toggleElement(selection, data, variables = {}, where) {
67365
67367
  if (!this.remove(data, variables)) {
67366
- this.addToList(selection2, data, variables, where);
67368
+ this.addToList(selection, data, variables, where);
67367
67369
  }
67368
67370
  }
67369
67371
  *[Symbol.iterator]() {
@@ -67938,14 +67940,24 @@ var InMemorySubscriptions = class {
67938
67940
  add({
67939
67941
  parent,
67940
67942
  spec,
67941
- selection: selection2,
67943
+ selection,
67942
67944
  variables,
67943
67945
  parentType
67944
67946
  }) {
67945
67947
  const __typename = this.cache._internal_unstable.storage.get(parent, "__typename").value;
67946
- let targetSelection = getFieldsForType(selection2, __typename);
67948
+ let targetSelection = getFieldsForType(selection, __typename);
67947
67949
  for (const fieldSelection of Object.values(targetSelection || {})) {
67948
- const { keyRaw, selection: innerSelection, type, list, filters } = fieldSelection;
67950
+ const {
67951
+ keyRaw,
67952
+ selection: innerSelection,
67953
+ type,
67954
+ list,
67955
+ filters,
67956
+ visible
67957
+ } = fieldSelection;
67958
+ if (!visible) {
67959
+ continue;
67960
+ }
67949
67961
  const key = evaluateKey(keyRaw, variables);
67950
67962
  let targetSelection2;
67951
67963
  if (innerSelection) {
@@ -67993,10 +68005,10 @@ var InMemorySubscriptions = class {
67993
68005
  addFieldSubscription({
67994
68006
  id,
67995
68007
  key,
67996
- selection: selection2,
68008
+ selection,
67997
68009
  type
67998
68010
  }) {
67999
- const spec = selection2[0];
68011
+ const spec = selection[0];
68000
68012
  if (!this.subscribers[id]) {
68001
68013
  this.subscribers[id] = {};
68002
68014
  }
@@ -68008,7 +68020,7 @@ var InMemorySubscriptions = class {
68008
68020
  }
68009
68021
  this.keyVersions[key].add(key);
68010
68022
  if (!this.subscribers[id][key].map(([{ set }]) => set).includes(spec.set)) {
68011
- this.subscribers[id][key].push([spec, selection2[1]]);
68023
+ this.subscribers[id][key].push([spec, selection[1]]);
68012
68024
  }
68013
68025
  if (!this.referenceCounts[id]) {
68014
68026
  this.referenceCounts[id] = {};
@@ -68019,14 +68031,13 @@ var InMemorySubscriptions = class {
68019
68031
  const counts = this.referenceCounts[id][key];
68020
68032
  counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
68021
68033
  this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
68022
- const { selection: innerSelection } = selection2[1]?.[key] ?? {};
68023
68034
  }
68024
68035
  registerList({
68025
68036
  list,
68026
68037
  id,
68027
68038
  key,
68028
68039
  parentType,
68029
- selection: selection2,
68040
+ selection,
68030
68041
  filters,
68031
68042
  variables
68032
68043
  }) {
@@ -68037,7 +68048,7 @@ var InMemorySubscriptions = class {
68037
68048
  recordType: this.cache._internal_unstable.storage.get(id, "__typename")?.value || parentType,
68038
68049
  listType: list.type,
68039
68050
  key,
68040
- selection: selection2,
68051
+ selection,
68041
68052
  filters: Object.entries(filters || {}).reduce((acc, [key2, { kind, value }]) => {
68042
68053
  return {
68043
68054
  ...acc,
@@ -68053,14 +68064,14 @@ var InMemorySubscriptions = class {
68053
68064
  parentType
68054
68065
  }) {
68055
68066
  for (const [spec, targetSelection] of subscribers) {
68056
- for (const selection2 of Object.values(targetSelection ?? {})) {
68067
+ for (const selection of Object.values(targetSelection ?? {})) {
68057
68068
  const {
68058
68069
  type: linkedType,
68059
68070
  keyRaw,
68060
68071
  selection: innerSelection,
68061
68072
  list,
68062
68073
  filters
68063
- } = selection2;
68074
+ } = selection;
68064
68075
  const key = evaluateKey(keyRaw, variables);
68065
68076
  const fieldSelection = innerSelection ? getFieldsForType(innerSelection, parentType) : void 0;
68066
68077
  this.addFieldSubscription({
@@ -68080,7 +68091,7 @@ var InMemorySubscriptions = class {
68080
68091
  parentType: parentType || spec.rootType
68081
68092
  });
68082
68093
  }
68083
- const childSelection = selection2.selection;
68094
+ const childSelection = selection.selection;
68084
68095
  if (childSelection) {
68085
68096
  const { value: link } = this.cache._internal_unstable.storage.get(parent, key);
68086
68097
  const children = !Array.isArray(link) ? [link] : flatten(link);
@@ -68107,11 +68118,11 @@ var InMemorySubscriptions = class {
68107
68118
  get(id, field) {
68108
68119
  return this.subscribers[id]?.[field] || [];
68109
68120
  }
68110
- remove(id, selection2, targets, variables, visited = []) {
68121
+ remove(id, selection, targets, variables, visited = []) {
68111
68122
  visited.push(id);
68112
68123
  const linkedIDs = [];
68113
68124
  const __typename = this.cache._internal_unstable.storage.get(id, "__typename").value;
68114
- let targetSelection = getFieldsForType(selection2, __typename);
68125
+ let targetSelection = getFieldsForType(selection, __typename);
68115
68126
  for (const fieldSelection of Object.values(targetSelection || {})) {
68116
68127
  const key = evaluateKey(fieldSelection.keyRaw, variables);
68117
68128
  this.removeSubscribers(id, key, targets);
@@ -68173,7 +68184,7 @@ var InMemorySubscriptions = class {
68173
68184
  // src/runtime/cache/cache.ts
68174
68185
  var Cache = class {
68175
68186
  _internal_unstable;
68176
- constructor(config4) {
68187
+ constructor({ disabled, ...config4 } = {}) {
68177
68188
  this._internal_unstable = new CacheInternal({
68178
68189
  cache: this,
68179
68190
  storage: new InMemoryStorage(),
@@ -68181,9 +68192,10 @@ var Cache = class {
68181
68192
  lists: new ListManager(this, rootID),
68182
68193
  lifetimes: new GarbageCollector(this),
68183
68194
  staleManager: new StaleManager(this),
68184
- schema: new SchemaManager(this)
68195
+ schema: new SchemaManager(this),
68196
+ disabled: disabled ?? typeof globalThis.window === "undefined"
68185
68197
  });
68186
- if (config4) {
68198
+ if (Object.keys(config4).length > 0) {
68187
68199
  this.setConfig(defaultConfigValues(config4));
68188
68200
  }
68189
68201
  }
@@ -68202,7 +68214,8 @@ var Cache = class {
68202
68214
  this._internal_unstable.getSelection({
68203
68215
  parent: spec.parentID || rootID,
68204
68216
  selection: spec.selection,
68205
- variables: spec.variables?.() || {}
68217
+ variables: spec.variables?.() || {},
68218
+ ignoreMasking: false
68206
68219
  }).data
68207
68220
  );
68208
68221
  }
@@ -68277,16 +68290,13 @@ var Cache = class {
68277
68290
  getFieldTime(id, field) {
68278
68291
  return this._internal_unstable.staleManager.getFieldTime(id, field);
68279
68292
  }
68293
+ config() {
68294
+ return this._internal_unstable.config;
68295
+ }
68280
68296
  };
68281
68297
  var CacheInternal = class {
68282
68298
  _disabled = false;
68283
- config = defaultConfigValues({
68284
- plugins: {
68285
- "houdini-svelte": {
68286
- client: ""
68287
- }
68288
- }
68289
- });
68299
+ _config;
68290
68300
  storage;
68291
68301
  subscriptions;
68292
68302
  lists;
@@ -68301,7 +68311,9 @@ var CacheInternal = class {
68301
68311
  cache,
68302
68312
  lifetimes,
68303
68313
  staleManager,
68304
- schema
68314
+ schema,
68315
+ disabled,
68316
+ config: config4
68305
68317
  }) {
68306
68318
  this.storage = storage;
68307
68319
  this.subscriptions = subscriptions;
@@ -68310,7 +68322,8 @@ var CacheInternal = class {
68310
68322
  this.lifetimes = lifetimes;
68311
68323
  this.staleManager = staleManager;
68312
68324
  this.schema = schema;
68313
- this._disabled = typeof globalThis.window === "undefined";
68325
+ this._config = config4;
68326
+ this._disabled = disabled;
68314
68327
  try {
68315
68328
  if (process.env.HOUDINI_TEST === "true") {
68316
68329
  this._disabled = false;
@@ -68318,12 +68331,15 @@ var CacheInternal = class {
68318
68331
  } catch {
68319
68332
  }
68320
68333
  }
68334
+ get config() {
68335
+ return this._config ?? getCurrentConfig();
68336
+ }
68321
68337
  setConfig(config4) {
68322
- this.config = config4;
68338
+ this._config = config4;
68323
68339
  }
68324
68340
  writeSelection({
68325
68341
  data,
68326
- selection: selection2,
68342
+ selection,
68327
68343
  variables = {},
68328
68344
  parent = rootID,
68329
68345
  applyUpdates,
@@ -68335,9 +68351,9 @@ var CacheInternal = class {
68335
68351
  if (this._disabled) {
68336
68352
  return [];
68337
68353
  }
68338
- let targetSelection = getFieldsForType(selection2, data["__typename"]);
68354
+ let targetSelection = getFieldsForType(selection, data["__typename"]);
68339
68355
  for (const [field, value] of Object.entries(data)) {
68340
- if (!selection2 || !targetSelection[field]) {
68356
+ if (!selection || !targetSelection[field]) {
68341
68357
  continue;
68342
68358
  }
68343
68359
  let {
@@ -68593,25 +68609,40 @@ var CacheInternal = class {
68593
68609
  return toNotify;
68594
68610
  }
68595
68611
  getSelection({
68596
- selection: selection2,
68612
+ selection,
68597
68613
  parent = rootID,
68598
68614
  variables,
68599
- stepsFromConnection = null
68615
+ stepsFromConnection = null,
68616
+ ignoreMasking
68600
68617
  }) {
68601
68618
  if (parent === null) {
68602
68619
  return { data: null, partial: false, stale: false, hasData: true };
68603
68620
  }
68604
68621
  const target = {};
68622
+ if (selection.fragments) {
68623
+ target[fragmentKey] = Object.fromEntries(
68624
+ Object.entries(selection.fragments).map(([key, value]) => [
68625
+ key,
68626
+ {
68627
+ parent,
68628
+ variables: evaluateFragmentVariables(value, variables ?? {})
68629
+ }
68630
+ ])
68631
+ );
68632
+ }
68605
68633
  let hasData = false;
68606
68634
  let partial = false;
68607
68635
  let cascadeNull = false;
68608
68636
  let stale = false;
68609
68637
  const typename = this.storage.get(parent, "__typename").value;
68610
- let targetSelection = getFieldsForType(selection2, typename);
68638
+ let targetSelection = getFieldsForType(selection, typename);
68611
68639
  for (const [
68612
68640
  attributeName,
68613
- { type, keyRaw, selection: fieldSelection, nullable, list }
68641
+ { type, keyRaw, selection: fieldSelection, nullable, list, visible }
68614
68642
  ] of Object.entries(targetSelection)) {
68643
+ if (!visible && !ignoreMasking) {
68644
+ continue;
68645
+ }
68615
68646
  const key = evaluateKey(keyRaw, variables);
68616
68647
  const { value } = this.storage.get(parent, key);
68617
68648
  const dt_field = this.staleManager.getFieldTime(parent, key);
@@ -68651,7 +68682,8 @@ var CacheInternal = class {
68651
68682
  fields: fieldSelection,
68652
68683
  variables,
68653
68684
  linkedList: value,
68654
- stepsFromConnection: nextStep
68685
+ stepsFromConnection: nextStep,
68686
+ ignoreMasking: !!ignoreMasking
68655
68687
  });
68656
68688
  target[attributeName] = listValue.data;
68657
68689
  if (listValue.partial) {
@@ -68668,7 +68700,8 @@ var CacheInternal = class {
68668
68700
  parent: value,
68669
68701
  selection: fieldSelection,
68670
68702
  variables,
68671
- stepsFromConnection: nextStep
68703
+ stepsFromConnection: nextStep,
68704
+ ignoreMasking
68672
68705
  });
68673
68706
  target[attributeName] = objectFields.data;
68674
68707
  if (objectFields.partial) {
@@ -68712,7 +68745,8 @@ var CacheInternal = class {
68712
68745
  fields,
68713
68746
  variables,
68714
68747
  linkedList,
68715
- stepsFromConnection
68748
+ stepsFromConnection,
68749
+ ignoreMasking
68716
68750
  }) {
68717
68751
  const result = [];
68718
68752
  let partialData = false;
@@ -68724,7 +68758,8 @@ var CacheInternal = class {
68724
68758
  fields,
68725
68759
  variables,
68726
68760
  linkedList: entry,
68727
- stepsFromConnection
68761
+ stepsFromConnection,
68762
+ ignoreMasking
68728
68763
  });
68729
68764
  result.push(nestedValue.data);
68730
68765
  if (nestedValue.partial) {
@@ -68745,7 +68780,8 @@ var CacheInternal = class {
68745
68780
  parent: entry,
68746
68781
  selection: fields,
68747
68782
  variables,
68748
- stepsFromConnection
68783
+ stepsFromConnection,
68784
+ ignoreMasking
68749
68785
  });
68750
68786
  result.push(data);
68751
68787
  if (partial) {
@@ -68848,11 +68884,54 @@ var CacheInternal = class {
68848
68884
  }
68849
68885
  }
68850
68886
  };
68887
+ function evaluateFragmentVariables(variables, args) {
68888
+ return Object.fromEntries(
68889
+ Object.entries(variables).map(([key, value]) => [key, fragmentVariableValue(value, args)])
68890
+ );
68891
+ }
68892
+ function fragmentVariableValue(value, args) {
68893
+ if (value.kind === "StringValue") {
68894
+ return value.value;
68895
+ }
68896
+ if (value.kind === "BooleanValue") {
68897
+ return value.value;
68898
+ }
68899
+ if (value.kind === "EnumValue") {
68900
+ return value.value;
68901
+ }
68902
+ if (value.kind === "FloatValue") {
68903
+ return parseFloat(value.value);
68904
+ }
68905
+ if (value.kind === "IntValue") {
68906
+ return parseInt(value.value, 10);
68907
+ }
68908
+ if (value.kind === "NullValue") {
68909
+ return null;
68910
+ }
68911
+ if (value.kind === "Variable") {
68912
+ return args[value.name.value];
68913
+ }
68914
+ if (value.kind === "ListValue") {
68915
+ return value.values.map((value2) => fragmentVariableValue(value2, args));
68916
+ }
68917
+ if (value.kind === "ObjectValue") {
68918
+ return value.fields.reduce(
68919
+ (obj, field) => ({
68920
+ ...obj,
68921
+ [field.name.value]: fragmentVariableValue(field.value, args)
68922
+ }),
68923
+ {}
68924
+ );
68925
+ }
68926
+ }
68851
68927
  var rootID = "_ROOT_";
68852
68928
 
68853
68929
  // src/runtime/cache/index.ts
68854
68930
  var cache_default = new Cache();
68855
68931
 
68932
+ // src/runtime/client/plugins/cache.ts
68933
+ var serverSide = typeof globalThis.window === "undefined";
68934
+
68856
68935
  // src/runtime/client/utils/documentPlugins.ts
68857
68936
  var documentPlugin = (kind, source) => {
68858
68937
  return () => {
@@ -68888,7 +68967,6 @@ var documentPlugin = (kind, source) => {
68888
68967
  var query = documentPlugin(ArtifactKind.Query, function() {
68889
68968
  let subscriptionSpec = null;
68890
68969
  let lastVariables = null;
68891
- let artifactName = "";
68892
68970
  return {
68893
68971
  start(ctx, { next }) {
68894
68972
  ctx.variables = {
@@ -68898,8 +68976,7 @@ var query = documentPlugin(ArtifactKind.Query, function() {
68898
68976
  next(ctx);
68899
68977
  },
68900
68978
  end(ctx, { resolve: resolve2, marshalVariables, variablesChanged }) {
68901
- if (variablesChanged(ctx)) {
68902
- artifactName = ctx.artifact.name;
68979
+ if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
68903
68980
  if (subscriptionSpec) {
68904
68981
  cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
68905
68982
  }
@@ -68920,19 +68997,61 @@ var query = documentPlugin(ArtifactKind.Query, function() {
68920
68997
  });
68921
68998
  }
68922
68999
  };
68923
- cache_default.subscribe(subscriptionSpec, lastVariables ?? {});
69000
+ cache_default.subscribe(subscriptionSpec, lastVariables);
68924
69001
  }
68925
69002
  resolve2(ctx);
68926
69003
  },
68927
69004
  cleanup() {
68928
69005
  if (subscriptionSpec) {
68929
- cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() ?? {});
69006
+ cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
68930
69007
  lastVariables = null;
68931
69008
  }
68932
69009
  }
68933
69010
  };
68934
69011
  });
68935
69012
 
69013
+ // src/runtime/client/plugins/fragment.ts
69014
+ var fragment = documentPlugin(ArtifactKind.Fragment, function() {
69015
+ let subscriptionSpec = null;
69016
+ return {
69017
+ start(ctx, { next, resolve: resolve2, variablesChanged, marshalVariables }) {
69018
+ if (!ctx.stuff.parentID) {
69019
+ return next(ctx);
69020
+ }
69021
+ if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
69022
+ if (subscriptionSpec) {
69023
+ cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
69024
+ }
69025
+ const variables = marshalVariables(ctx);
69026
+ subscriptionSpec = {
69027
+ rootType: ctx.artifact.rootType,
69028
+ selection: ctx.artifact.selection,
69029
+ variables: () => variables,
69030
+ parentID: ctx.stuff.parentID,
69031
+ set: (newValue) => {
69032
+ resolve2(ctx, {
69033
+ data: newValue,
69034
+ errors: null,
69035
+ fetching: false,
69036
+ partial: false,
69037
+ stale: false,
69038
+ source: DataSource.Cache,
69039
+ variables
69040
+ });
69041
+ }
69042
+ };
69043
+ cache_default.subscribe(subscriptionSpec, variables);
69044
+ }
69045
+ next(ctx);
69046
+ },
69047
+ cleanup() {
69048
+ if (subscriptionSpec) {
69049
+ cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
69050
+ }
69051
+ }
69052
+ };
69053
+ });
69054
+
68936
69055
  // src/runtime/client/plugins/mutation.ts
68937
69056
  var mutation = documentPlugin(ArtifactKind.Mutation, () => {
68938
69057
  return {
@@ -69088,6 +69207,7 @@ var Config = class {
69088
69207
  this.schemaPollInterval = watchSchema?.interval ?? 2e3;
69089
69208
  this.schemaPollHeaders = watchSchema?.headers ?? {};
69090
69209
  this.rootDir = join2(this.projectRoot, "$houdini");
69210
+ this.#fragmentVariableMaps = {};
69091
69211
  if (defaultKeys) {
69092
69212
  this.defaultKeys = defaultKeys;
69093
69213
  }
@@ -69237,7 +69357,7 @@ var Config = class {
69237
69357
  return `$houdini/${this.artifactDirectoryName}/${name}`;
69238
69358
  }
69239
69359
  keyFieldsForType(type) {
69240
- return keyFieldsForType(this.configFile, type);
69360
+ return this.schema.getQueryType()?.name === type ? [] : keyFieldsForType(this.configFile, type);
69241
69361
  }
69242
69362
  computeID(type, data) {
69243
69363
  return computeID(this.configFile, type, data);
@@ -69256,7 +69376,7 @@ var Config = class {
69256
69376
  ({ kind }) => kind === graphql2.Kind.FRAGMENT_DEFINITION
69257
69377
  );
69258
69378
  if (fragmentDefinitions.length) {
69259
- return fragmentDefinitions.map((fragment) => fragment.name.value).join("_");
69379
+ return fragmentDefinitions[0].name.value;
69260
69380
  }
69261
69381
  throw new Error("Could not generate artifact name for document: " + graphql2.print(document));
69262
69382
  }
@@ -69428,6 +69548,56 @@ var Config = class {
69428
69548
  }, []) ?? [];
69429
69549
  return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name));
69430
69550
  }
69551
+ #fragmentVariableMaps;
69552
+ registerFragmentVariablesHash({
69553
+ hash,
69554
+ args,
69555
+ fragment: fragment2
69556
+ }) {
69557
+ this.#fragmentVariableMaps[hash] = {
69558
+ args: this.#serializeValueMap(args),
69559
+ fragment: fragment2
69560
+ };
69561
+ }
69562
+ getFragmentVariablesHash(hash) {
69563
+ return this.#fragmentVariableMaps[hash] ?? {
69564
+ fragment: hash,
69565
+ args: {},
69566
+ hash
69567
+ };
69568
+ }
69569
+ #serializeValueMap(map) {
69570
+ if (!map) {
69571
+ return null;
69572
+ }
69573
+ return Object.fromEntries(
69574
+ Object.entries(map).map(([key, input]) => {
69575
+ const result = {
69576
+ kind: input.kind
69577
+ };
69578
+ if (typeof input === "object") {
69579
+ if ("value" in input) {
69580
+ result.value = input.value;
69581
+ }
69582
+ if ("values" in input) {
69583
+ result.values = input.values.map(
69584
+ (value) => this.#serializeValueMap({ foo: value }).foo
69585
+ );
69586
+ }
69587
+ if ("name" in input) {
69588
+ result.name = input.name;
69589
+ }
69590
+ if ("fields" in input) {
69591
+ result.fields = input.fields.map((field) => ({
69592
+ name: field.name,
69593
+ value: this.#serializeValueMap({ foo: field.value }).foo
69594
+ }));
69595
+ }
69596
+ }
69597
+ return [key, result];
69598
+ })
69599
+ );
69600
+ }
69431
69601
  isListFragment(name) {
69432
69602
  return name.endsWith(this.insertFragmentSuffix) || name.endsWith(this.removeFragmentSuffix) || name.endsWith(this.toggleFragmentSuffix);
69433
69603
  }
@@ -69929,11 +70099,17 @@ function deepMerge(filepath, ...targets) {
69929
70099
  if (targets.length === 1) {
69930
70100
  return targets[0];
69931
70101
  } else if (targets.length === 2) {
69932
- return (0, import_deepmerge.default)(targets[0], targets[1]);
70102
+ return (0, import_deepmerge.default)(targets[0], targets[1], {
70103
+ arrayMerge: (source, update) => [...new Set(source.concat(update))]
70104
+ });
69933
70105
  }
69934
70106
  return deepMerge(filepath, targets[0], deepMerge(filepath, ...targets.slice(1)));
69935
70107
  } catch (e2) {
69936
- throw new HoudiniError({ filepath, message: "could not merge: " + targets });
70108
+ throw new HoudiniError({
70109
+ filepath,
70110
+ message: "could not merge: " + targets,
70111
+ description: e2.message
70112
+ });
69937
70113
  }
69938
70114
  }
69939
70115
 
@@ -70161,16 +70337,16 @@ function flattenSelections({
70161
70337
  filepath,
70162
70338
  selections,
70163
70339
  fragmentDefinitions,
70164
- applyFragments,
70165
- ignoreMaskDisable
70340
+ ignoreMaskDisable,
70341
+ keepFragmentSpreadNodes
70166
70342
  }) {
70167
70343
  const fields = new FieldCollection({
70168
70344
  config: config4,
70169
70345
  filepath,
70170
70346
  selections,
70171
70347
  fragmentDefinitions,
70172
- applyFragments,
70173
- ignoreMaskDisable: !!ignoreMaskDisable
70348
+ ignoreMaskDisable: !!ignoreMaskDisable,
70349
+ keepFragmentSpreadNodes: !!keepFragmentSpreadNodes
70174
70350
  });
70175
70351
  return fields.toSelectionSet();
70176
70352
  }
@@ -70181,57 +70357,60 @@ var FieldCollection = class {
70181
70357
  fields;
70182
70358
  inlineFragments;
70183
70359
  fragmentSpreads;
70184
- applyFragments;
70185
70360
  ignoreMaskDisable;
70361
+ keepFragmentSpreadNodes;
70186
70362
  constructor(args) {
70187
70363
  this.config = args.config;
70188
70364
  this.fragmentDefinitions = args.fragmentDefinitions;
70189
- this.applyFragments = args.applyFragments;
70190
70365
  this.ignoreMaskDisable = args.ignoreMaskDisable;
70366
+ this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
70191
70367
  this.fields = {};
70192
70368
  this.inlineFragments = {};
70193
70369
  this.fragmentSpreads = {};
70194
70370
  this.filepath = args.filepath;
70195
- for (const selection2 of args.selections) {
70196
- this.add(selection2);
70371
+ for (const selection of args.selections) {
70372
+ this.add(selection);
70197
70373
  }
70198
70374
  }
70199
70375
  get size() {
70200
70376
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
70201
70377
  }
70202
- add(selection2) {
70203
- if (selection2.kind === "Field") {
70204
- const key = selection2.alias?.value || selection2.name.value;
70378
+ add(selection) {
70379
+ if (selection.kind === "Field") {
70380
+ const key = selection.alias?.value || selection.name.value;
70205
70381
  if (!this.fields[key]) {
70206
70382
  this.fields[key] = {
70207
- astNode: selection2,
70383
+ astNode: selection,
70208
70384
  selection: this.empty()
70209
70385
  };
70210
70386
  }
70211
- for (const subselect of selection2.selectionSet?.selections || []) {
70387
+ for (const subselect of selection.selectionSet?.selections || []) {
70212
70388
  this.fields[key].selection.add(subselect);
70213
70389
  }
70390
+ this.fields[key].selection.fragmentSpreads = {
70391
+ ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
70392
+ ...this.fields[key].selection.fragmentSpreads
70393
+ };
70214
70394
  return;
70215
70395
  }
70216
- if (selection2.kind === "InlineFragment" && !selection2.typeCondition) {
70217
- for (const subselect of selection2.selectionSet.selections) {
70396
+ if (selection.kind === "InlineFragment" && !selection.typeCondition) {
70397
+ for (const subselect of selection.selectionSet.selections) {
70218
70398
  this.add(subselect);
70219
70399
  }
70220
70400
  }
70221
- if (selection2.kind === "InlineFragment" && selection2.typeCondition) {
70222
- this.walkInlineFragment(selection2);
70401
+ if (selection.kind === "InlineFragment" && selection.typeCondition) {
70402
+ this.walkInlineFragment(selection);
70223
70403
  return;
70224
70404
  }
70225
- if (selection2.kind === "FragmentSpread") {
70226
- this.fragmentSpreads[selection2.name.value] = selection2;
70405
+ if (selection.kind === "FragmentSpread") {
70227
70406
  let includeFragments = this.config.defaultFragmentMasking === "disable";
70228
- const maskEnableDirective = selection2.directives?.find(
70407
+ const maskEnableDirective = selection.directives?.find(
70229
70408
  ({ name }) => name.value === this.config.maskEnableDirective
70230
70409
  );
70231
70410
  if (maskEnableDirective) {
70232
70411
  includeFragments = false;
70233
70412
  }
70234
- const maskDisableDirective = selection2.directives?.find(
70413
+ const maskDisableDirective = selection.directives?.find(
70235
70414
  ({ name }) => name.value === this.config.maskDisableDirective
70236
70415
  );
70237
70416
  if (maskDisableDirective) {
@@ -70240,14 +70419,17 @@ var FieldCollection = class {
70240
70419
  if (this.ignoreMaskDisable) {
70241
70420
  includeFragments = true;
70242
70421
  }
70243
- if (!includeFragments || !this.applyFragments) {
70422
+ if (this.keepFragmentSpreadNodes) {
70423
+ this.fragmentSpreads[selection.name.value] = selection;
70424
+ }
70425
+ if (!includeFragments) {
70244
70426
  return;
70245
70427
  }
70246
- const definition = this.fragmentDefinitions[selection2.name.value];
70428
+ const definition = this.fragmentDefinitions[selection.name.value];
70247
70429
  if (!definition) {
70248
70430
  throw new HoudiniError({
70249
70431
  filepath: this.filepath,
70250
- message: "Could not find referenced fragment definition: " + selection2.name.value
70432
+ message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
70251
70433
  });
70252
70434
  }
70253
70435
  this.add({
@@ -70266,37 +70448,67 @@ var FieldCollection = class {
70266
70448
  });
70267
70449
  }
70268
70450
  }
70451
+ collectFragmentSpreads(selections, result = {}) {
70452
+ for (const selection of selections) {
70453
+ if (selection.kind === "Field") {
70454
+ continue;
70455
+ }
70456
+ if (selection.kind === "InlineFragment") {
70457
+ this.collectFragmentSpreads(selection.selectionSet.selections, result);
70458
+ continue;
70459
+ }
70460
+ if (selection.kind === "FragmentSpread") {
70461
+ result[selection.name.value] = selection;
70462
+ continue;
70463
+ }
70464
+ }
70465
+ return result;
70466
+ }
70269
70467
  toSelectionSet() {
70270
- return Object.values(this.inlineFragments).flatMap((fragment) => {
70271
- if (fragment.selection.size === 0) {
70468
+ return Object.values(this.inlineFragments).flatMap((fragment2) => {
70469
+ if (fragment2.selection.size === 0) {
70272
70470
  return [];
70273
70471
  }
70274
- fragment.astNode = {
70275
- ...fragment.astNode,
70472
+ fragment2.astNode = {
70473
+ ...fragment2.astNode,
70276
70474
  selectionSet: {
70277
- ...fragment.astNode.selectionSet,
70278
- selections: fragment.selection.toSelectionSet()
70475
+ ...fragment2.astNode.selectionSet,
70476
+ selections: fragment2.selection.toSelectionSet()
70279
70477
  }
70280
70478
  };
70281
- return [fragment.astNode];
70479
+ return [fragment2.astNode];
70282
70480
  }).concat(
70283
70481
  Object.values(this.fields).map((field) => {
70284
- if (field.astNode.selectionSet) {
70285
- field.astNode.selectionSet.selections = field.selection.toSelectionSet();
70286
- }
70287
- return field.astNode;
70482
+ return {
70483
+ ...field.astNode,
70484
+ selectionSet: field.astNode.selectionSet ? {
70485
+ kind: "SelectionSet",
70486
+ selections: field.selection.toSelectionSet()
70487
+ } : void 0
70488
+ };
70288
70489
  })
70289
- ).concat(Object.values(this.fragmentSpreads));
70490
+ ).concat(
70491
+ Object.values(this.fragmentSpreads).map((spread) => {
70492
+ return {
70493
+ kind: "FragmentSpread",
70494
+ name: {
70495
+ kind: "Name",
70496
+ value: spread.name.value
70497
+ },
70498
+ directives: spread.directives
70499
+ };
70500
+ })
70501
+ );
70290
70502
  }
70291
- walkInlineFragment(selection2) {
70292
- const key = selection2.typeCondition.name.value;
70503
+ walkInlineFragment(selection) {
70504
+ const key = selection.typeCondition.name.value;
70293
70505
  if (!this.inlineFragments[key]) {
70294
70506
  this.inlineFragments[key] = {
70295
- astNode: selection2,
70507
+ astNode: selection,
70296
70508
  selection: this.empty()
70297
70509
  };
70298
70510
  }
70299
- for (const subselect of selection2.selectionSet.selections || []) {
70511
+ for (const subselect of selection.selectionSet.selections || []) {
70300
70512
  if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
70301
70513
  this.inlineFragments[key].selection.add(subselect);
70302
70514
  continue;
@@ -70310,8 +70522,8 @@ var FieldCollection = class {
70310
70522
  fragmentDefinitions: this.fragmentDefinitions,
70311
70523
  selections: [],
70312
70524
  filepath: this.filepath,
70313
- applyFragments: this.applyFragments,
70314
- ignoreMaskDisable: this.ignoreMaskDisable
70525
+ ignoreMaskDisable: this.ignoreMaskDisable,
70526
+ keepFragmentSpreadNodes: this.keepFragmentSpreadNodes
70315
70527
  });
70316
70528
  }
70317
70529
  };
@@ -70389,13 +70601,13 @@ function murmurHash(str) {
70389
70601
  // src/codegen/transforms/fragmentVariables.ts
70390
70602
  var graphql5 = __toESM(require_graphql2(), 1);
70391
70603
 
70392
- // src/codegen/transforms/composeQueries.ts
70604
+ // src/codegen/transforms/collectDefinitions.ts
70393
70605
  var import_graphql30 = __toESM(require_graphql2(), 1);
70394
70606
  async function includeFragmentDefinitions(config4, documents) {
70395
- const fragments = collectFragments(config4, documents);
70607
+ const fragments = collectDefinitions(config4, documents);
70396
70608
  for (const [index, { name, document, filename }] of documents.entries()) {
70397
70609
  const operation = document.definitions.find(
70398
- ({ kind }) => kind === import_graphql30.Kind.OPERATION_DEFINITION
70610
+ (def) => def.kind === import_graphql30.Kind.OPERATION_DEFINITION || def.kind === "FragmentDefinition"
70399
70611
  );
70400
70612
  if (!operation) {
70401
70613
  continue;
@@ -70414,7 +70626,7 @@ async function includeFragmentDefinitions(config4, documents) {
70414
70626
  };
70415
70627
  }
70416
70628
  }
70417
- function collectFragments(config4, docs) {
70629
+ function collectDefinitions(config4, docs) {
70418
70630
  return docs.reduce((acc, doc) => {
70419
70631
  const definitions = doc.document.definitions.reduce(
70420
70632
  (prev, definition) => definition.kind !== "FragmentDefinition" ? prev : {
@@ -70438,11 +70650,11 @@ function findRequiredFragments(selectionSet) {
70438
70650
  return [];
70439
70651
  }
70440
70652
  const referencedFragments = [];
70441
- for (const selection2 of selectionSet.selections) {
70442
- if (selection2.kind === import_graphql30.Kind.FRAGMENT_SPREAD) {
70443
- referencedFragments.push(selection2.name.value);
70444
- } else if (selection2.selectionSet) {
70445
- referencedFragments.push(...findRequiredFragments(selection2.selectionSet));
70653
+ for (const selection of selectionSet.selections) {
70654
+ if (selection.kind === import_graphql30.Kind.FRAGMENT_SPREAD) {
70655
+ referencedFragments.push(selection.name.value);
70656
+ } else if (selection.selectionSet) {
70657
+ referencedFragments.push(...findRequiredFragments(selection.selectionSet));
70446
70658
  }
70447
70659
  }
70448
70660
  return referencedFragments;
@@ -70475,7 +70687,7 @@ function flattenFragments(filepath, operation, fragments) {
70475
70687
  // src/codegen/transforms/fragmentVariables.ts
70476
70688
  var GraphqlKinds2 = graphql5.Kind;
70477
70689
  async function fragmentVariables(config4, documents) {
70478
- const fragments = collectFragments(config4, documents);
70690
+ const fragments = collectDefinitions(config4, documents);
70479
70691
  const generatedFragments = {};
70480
70692
  const visitedFragments = /* @__PURE__ */ new Set();
70481
70693
  for (const doc2 of documents) {
@@ -70535,9 +70747,17 @@ function inlineFragmentArgs({
70535
70747
  ).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
70536
70748
  const result = graphql5.visit(document, {
70537
70749
  FragmentSpread(node) {
70750
+ if (!fragmentDefinitions[node.name.value]) {
70751
+ throw new Error("Could not find definition for fragment" + node.name.value);
70752
+ }
70538
70753
  const { definition } = fragmentDefinitions[node.name.value];
70539
70754
  let { args, hash } = collectWithArguments(config4, filepath, node, scope);
70540
70755
  const newFragmentName = `${node.name.value}${hash}`;
70756
+ config4.registerFragmentVariablesHash({
70757
+ hash: newFragmentName,
70758
+ fragment: node.name.value,
70759
+ args
70760
+ });
70541
70761
  if (!visitedFragments.has(newFragmentName)) {
70542
70762
  visitedFragments.add(newFragmentName);
70543
70763
  const defaultArguments = collectDefaultArgumentValues(config4, filepath, definition);
@@ -70936,7 +71156,7 @@ function operationObject({
70936
71156
  listName,
70937
71157
  operationKind,
70938
71158
  type,
70939
- selection: selection2,
71159
+ selection,
70940
71160
  filepath
70941
71161
  }) {
70942
71162
  let parentID;
@@ -70944,7 +71164,7 @@ function operationObject({
70944
71164
  let position = config4.internalListPosition;
70945
71165
  let allLists = config4.defaultListTarget ?? void 0;
70946
71166
  let operationWhen;
70947
- const internalDirectives = selection2.directives?.filter(
71167
+ const internalDirectives = selection.directives?.filter(
70948
71168
  (directive) => config4.isInternalDirective(directive.name.value)
70949
71169
  );
70950
71170
  if (internalDirectives && internalDirectives.length > 0) {
@@ -71186,7 +71406,7 @@ async function paginate(config4, documents) {
71186
71406
  let fragmentName = "";
71187
71407
  let refetchQueryName = "";
71188
71408
  let nodeQuery = false;
71189
- let fragment = "";
71409
+ let fragment2 = "";
71190
71410
  let paginateMode = config4.defaultPaginateMode;
71191
71411
  doc.document = graphql10.visit(doc.document, {
71192
71412
  OperationDefinition(node) {
@@ -71229,7 +71449,7 @@ async function paginate(config4, documents) {
71229
71449
  };
71230
71450
  },
71231
71451
  FragmentDefinition(node) {
71232
- fragment = node.typeCondition.name.value;
71452
+ fragment2 = node.typeCondition.name.value;
71233
71453
  fragmentName = node.name.value;
71234
71454
  refetchQueryName = config4.paginationQueryName(fragmentName);
71235
71455
  nodeQuery = node.typeCondition.name.value !== config4.schema.getQueryType()?.name;
@@ -71276,17 +71496,17 @@ async function paginate(config4, documents) {
71276
71496
  }
71277
71497
  });
71278
71498
  let targetType = config4.schema.getQueryType()?.name || "";
71279
- if (fragment) {
71499
+ if (fragment2) {
71280
71500
  const nodeInterface = config4.schema.getType("Node");
71281
71501
  if (nodeInterface) {
71282
71502
  const { objects, interfaces } = config4.schema.getImplementations(nodeInterface);
71283
- if (objects.find((obj) => obj.name === fragment) || interfaces.find((int) => int.name === fragment)) {
71503
+ if (objects.find((obj) => obj.name === fragment2) || interfaces.find((int) => int.name === fragment2)) {
71284
71504
  targetType = "Node";
71285
71505
  } else {
71286
- targetType = fragment;
71506
+ targetType = fragment2;
71287
71507
  }
71288
71508
  } else {
71289
- targetType = fragment;
71509
+ targetType = fragment2;
71290
71510
  }
71291
71511
  }
71292
71512
  const pageSize = flags.first.defaultValue ?? flags.last.defaultValue ?? flags.limit.defaultValue;
@@ -71308,7 +71528,7 @@ async function paginate(config4, documents) {
71308
71528
  start,
71309
71529
  mode: paginateMode
71310
71530
  };
71311
- if (!fragment) {
71531
+ if (!fragment2) {
71312
71532
  continue;
71313
71533
  }
71314
71534
  const paginationArgs = Object.entries(flags).filter(([_, { enabled }]) => enabled).map(([key, value]) => ({ name: key, ...value }));
@@ -71329,15 +71549,22 @@ async function paginate(config4, documents) {
71329
71549
  ["arguments"]: paginationArgs.map(
71330
71550
  ({ name }) => variableAsArgument(name)
71331
71551
  )
71552
+ },
71553
+ {
71554
+ kind: graphql10.Kind.DIRECTIVE,
71555
+ name: {
71556
+ kind: "Name",
71557
+ value: config4.maskDisableDirective
71558
+ }
71332
71559
  }
71333
71560
  ]
71334
71561
  }
71335
71562
  ];
71336
- const keys = config4.keyFieldsForType(!nodeQuery ? config4.schema.getQueryType()?.name || "" : fragment).flatMap((key) => {
71337
- if (fragment === config4.schema.getQueryType()?.name) {
71563
+ const keys = config4.keyFieldsForType(!nodeQuery ? config4.schema.getQueryType()?.name || "" : fragment2).flatMap((key) => {
71564
+ if (fragment2 === config4.schema.getQueryType()?.name) {
71338
71565
  return [];
71339
71566
  }
71340
- const fragmentType = config4.schema.getType(fragment);
71567
+ const fragmentType = config4.schema.getType(fragment2);
71341
71568
  const { type, wrappers } = unwrapType(
71342
71569
  config4,
71343
71570
  fragmentType.getFields()[key].type
@@ -71349,7 +71576,7 @@ async function paginate(config4, documents) {
71349
71576
  }
71350
71577
  ];
71351
71578
  });
71352
- const typeConfig = config4.typeConfig?.[fragment];
71579
+ const typeConfig = config4.typeConfig?.[fragment2];
71353
71580
  const queryDoc = {
71354
71581
  kind: graphql10.Kind.DOCUMENT,
71355
71582
  definitions: [
@@ -71691,7 +71918,7 @@ async function addListFragments(config4, documents) {
71691
71918
  );
71692
71919
  const targetField = ancestors[ancestors.length - 1];
71693
71920
  const targetFieldDefinition = parentType.getFields()[targetField.name.value];
71694
- const { selection: selection2, type, connection } = connectionSelection(
71921
+ const { selection, type, connection } = connectionSelection(
71695
71922
  config4,
71696
71923
  targetFieldDefinition,
71697
71924
  parentTypeFromAncestors(
@@ -71702,7 +71929,7 @@ async function addListFragments(config4, documents) {
71702
71929
  ancestors[ancestors.length - 1].selectionSet
71703
71930
  );
71704
71931
  lists[nameArg.value.value] = {
71705
- selection: selection2,
71932
+ selection,
71706
71933
  type,
71707
71934
  filename: doc.filename
71708
71935
  };
@@ -71780,14 +72007,14 @@ async function addListFragments(config4, documents) {
71780
72007
  const generatedDoc = {
71781
72008
  kind: graphql11.Kind.DOCUMENT,
71782
72009
  definitions: Object.entries(lists).flatMap(
71783
- ([name, { selection: selection2, type }]) => {
72010
+ ([name, { selection, type }]) => {
71784
72011
  const schemaType = config4.schema.getType(type.name);
71785
- if (!selection2) {
72012
+ if (!selection) {
71786
72013
  throw new HoudiniError({ message: "Lists must have a selection" });
71787
72014
  }
71788
72015
  const fragmentSelection = {
71789
72016
  kind: graphql11.Kind.SELECTION_SET,
71790
- selections: [...selection2.selections]
72017
+ selections: [...selection.selections]
71791
72018
  };
71792
72019
  if (schemaType && fragmentSelection && !fragmentSelection?.selections.find(
71793
72020
  (field) => field.kind === "Field" && config4.keyFieldsForType(type.name).includes(field.name.value)
@@ -71879,7 +72106,7 @@ async function addListFragments(config4, documents) {
71879
72106
  artifact: null
71880
72107
  });
71881
72108
  }
71882
- function connectionSelection(config4, field, type, selection2) {
72109
+ function connectionSelection(config4, field, type, selection) {
71883
72110
  const fieldArgs = field.args.reduce(
71884
72111
  (args, arg) => ({
71885
72112
  ...args,
@@ -71888,34 +72115,34 @@ function connectionSelection(config4, field, type, selection2) {
71888
72115
  {}
71889
72116
  );
71890
72117
  if (fieldArgs["limit"]) {
71891
- return { selection: selection2, type, connection: false, error: null };
72118
+ return { selection, type, connection: false, error: null };
71892
72119
  }
71893
72120
  const forwardPagination = fieldArgs["first"] === "Int" && ["Cursor", "String"].includes(fieldArgs["after"]);
71894
72121
  const backwardsPagination = fieldArgs["last"] === "Int" && ["Cursor", "String"].includes(fieldArgs["before"]);
71895
72122
  if (!forwardPagination && !backwardsPagination) {
71896
- return { selection: selection2, type, connection: false, error: missingPaginationArgMessage(config4) };
72123
+ return { selection, type, connection: false, error: missingPaginationArgMessage(config4) };
71897
72124
  }
71898
- const edgesField = selection2?.selections.find(
71899
- (selection3) => selection3.kind === "Field" && selection3.name.value === "edges"
72125
+ const edgesField = selection?.selections.find(
72126
+ (selection2) => selection2.kind === "Field" && selection2.name.value === "edges"
71900
72127
  );
71901
72128
  if (!edgesField) {
71902
- return { selection: selection2, type, connection: false, error: missingEdgeSelectionMessage(config4) };
72129
+ return { selection, type, connection: false, error: missingEdgeSelectionMessage(config4) };
71903
72130
  }
71904
72131
  const nodeSelection = edgesField.selectionSet?.selections.find(
71905
- (selection3) => selection3.kind === "Field" && selection3.name.value === "node"
72132
+ (selection2) => selection2.kind === "Field" && selection2.name.value === "node"
71906
72133
  );
71907
72134
  if (!nodeSelection.selectionSet) {
71908
- return { selection: selection2, type, connection: false, error: missingNodeSelectionMessage(config4) };
72135
+ return { selection, type, connection: false, error: missingNodeSelectionMessage(config4) };
71909
72136
  }
71910
72137
  const edgeField = unwrapType(config4, field.type).type.getFields()["edges"];
71911
72138
  const { wrappers, type: edgeFieldType } = unwrapType(config4, edgeField.type);
71912
72139
  const list = wrappers[wrappers.length - 2] === "List" /* List */;
71913
72140
  if (!list) {
71914
- return { selection: selection2, type, connection: false, error: edgeInvalidTypeMessage(config4) };
72141
+ return { selection, type, connection: false, error: edgeInvalidTypeMessage(config4) };
71915
72142
  }
71916
72143
  const nodeField = edgeFieldType.getFields()["node"];
71917
72144
  if (!nodeField) {
71918
- return { selection: selection2, type, connection: false, error: nodeNotDefinedMessage(config4) };
72145
+ return { selection, type, connection: false, error: nodeNotDefinedMessage(config4) };
71919
72146
  }
71920
72147
  return {
71921
72148
  selection: nodeSelection.selectionSet,
@@ -71994,59 +72221,45 @@ function fieldKey(config4, field) {
71994
72221
  }
71995
72222
 
71996
72223
  // src/codegen/generators/artifacts/selection.ts
71997
- function selection({
72224
+ function selection_default(args) {
72225
+ const typeMap = {};
72226
+ const abstractTypes = [];
72227
+ return mergeSelection({
72228
+ object: prepareSelection({ ...args, typeMap, abstractTypes }),
72229
+ filepath: args.filepath,
72230
+ typeMap,
72231
+ abstractTypes
72232
+ });
72233
+ }
72234
+ function prepareSelection({
71998
72235
  config: config4,
71999
72236
  filepath,
72000
72237
  rootType,
72001
72238
  selections,
72002
72239
  operations,
72003
72240
  path: path2 = [],
72004
- includeFragments,
72005
72241
  document,
72006
- inConnection
72242
+ inConnection,
72243
+ typeMap,
72244
+ abstractTypes
72007
72245
  }) {
72008
72246
  let object = {};
72009
- const typeMap = {};
72010
- const abstractTypes = [];
72011
72247
  for (const field of selections) {
72012
- if (field.kind === "FragmentSpread" && includeFragments) {
72013
- const fragmentDefinition = document.document.definitions.find(
72014
- (defn) => defn.kind === "FragmentDefinition" && defn.name.value === field.name.value
72015
- );
72016
- if (!fragmentDefinition) {
72017
- throw new HoudiniError({
72018
- filepath,
72019
- message: "selection: could not find definition for fragment " + field.name.value
72020
- });
72021
- }
72022
- object = deepMerge(
72023
- filepath,
72024
- object,
72025
- selection({
72026
- config: config4,
72027
- filepath,
72028
- rootType: fragmentDefinition.typeCondition.name.value,
72029
- operations,
72030
- selections: fragmentDefinition.selectionSet.selections,
72031
- path: path2,
72032
- includeFragments,
72033
- document
72034
- })
72035
- );
72036
- } else if (field.kind === "InlineFragment") {
72248
+ if (field.kind === "InlineFragment") {
72037
72249
  if (!field.typeCondition || field.typeCondition.name.value === rootType) {
72038
72250
  object.fields = deepMerge(
72039
72251
  filepath,
72040
72252
  object.fields || {},
72041
- selection({
72253
+ prepareSelection({
72042
72254
  config: config4,
72043
72255
  filepath,
72044
72256
  rootType: field.typeCondition?.name.value || rootType,
72045
72257
  operations,
72046
72258
  selections: field.selectionSet.selections,
72047
72259
  path: path2,
72048
- includeFragments,
72049
- document
72260
+ document,
72261
+ typeMap,
72262
+ abstractTypes
72050
72263
  }).fields || {}
72051
72264
  );
72052
72265
  } else {
@@ -72084,15 +72297,16 @@ function selection({
72084
72297
  }
72085
72298
  object.abstractFields.fields = {
72086
72299
  ...object.abstractFields.fields,
72087
- [field.typeCondition.name.value]: selection({
72300
+ [field.typeCondition.name.value]: prepareSelection({
72088
72301
  config: config4,
72089
72302
  filepath,
72090
72303
  rootType: field.typeCondition?.name.value || rootType,
72091
72304
  operations,
72092
72305
  selections: field.selectionSet.selections,
72093
72306
  path: path2,
72094
- includeFragments,
72095
- document
72307
+ document,
72308
+ typeMap,
72309
+ abstractTypes
72096
72310
  }).fields
72097
72311
  };
72098
72312
  }
@@ -72113,10 +72327,14 @@ function selection({
72113
72327
  }
72114
72328
  const typeName = fieldType.toString();
72115
72329
  const pathSoFar = path2.concat(attributeName);
72116
- const fieldObj = {
72330
+ const keys = config4.keyFieldsForType(rootType);
72331
+ let fieldObj = {
72117
72332
  type: typeName,
72118
72333
  keyRaw: fieldKey(config4, field)
72119
72334
  };
72335
+ if (keys.includes(field.name.value)) {
72336
+ fieldObj.visible = true;
72337
+ }
72120
72338
  if (nullable) {
72121
72339
  fieldObj.nullable = true;
72122
72340
  }
@@ -72164,16 +72382,17 @@ function selection({
72164
72382
  }
72165
72383
  if (field.selectionSet) {
72166
72384
  const connectionState = paginated && document.refetch?.method === "cursor" || continueConnection;
72167
- fieldObj.selection = selection({
72385
+ fieldObj.selection = prepareSelection({
72168
72386
  config: config4,
72169
72387
  filepath,
72170
72388
  rootType: typeName,
72171
72389
  selections: field.selectionSet.selections,
72172
72390
  operations,
72173
72391
  path: pathSoFar,
72174
- includeFragments,
72175
72392
  document,
72176
- inConnection: connectionState
72393
+ inConnection: connectionState,
72394
+ typeMap,
72395
+ abstractTypes
72177
72396
  });
72178
72397
  }
72179
72398
  if (field.arguments?.length && fieldObj.list) {
@@ -72188,12 +72407,29 @@ function selection({
72188
72407
  if (graphql13.isInterfaceType(fieldType) || graphql13.isUnionType(fieldType)) {
72189
72408
  fieldObj.abstract = true;
72190
72409
  }
72410
+ if (object.fields?.[attributeName]) {
72411
+ fieldObj = deepMerge(filepath, object.fields[attributeName], fieldObj);
72412
+ }
72191
72413
  object.fields = {
72192
72414
  ...object.fields,
72193
72415
  [attributeName]: fieldObj
72194
72416
  };
72417
+ } else if (field.kind === "FragmentSpread") {
72418
+ const { fragment: fragment2, args } = config4.getFragmentVariablesHash(field.name.value);
72419
+ object.fragments = {
72420
+ ...object.fragments,
72421
+ [fragment2]: args ?? {}
72422
+ };
72195
72423
  }
72196
72424
  }
72425
+ return object;
72426
+ }
72427
+ function mergeSelection({
72428
+ filepath,
72429
+ object,
72430
+ typeMap,
72431
+ abstractTypes
72432
+ }) {
72197
72433
  if (Object.keys(object.fields || {}).length > 0 && object.abstractFields && Object.keys(object.abstractFields.fields).length > 0) {
72198
72434
  for (const [typeName, possibles] of Object.entries(typeMap)) {
72199
72435
  let overlap = false;
@@ -72201,8 +72437,8 @@ function selection({
72201
72437
  if (object.abstractFields.fields[typeName]) {
72202
72438
  object.abstractFields.fields[typeName] = deepMerge(
72203
72439
  filepath,
72204
- object.abstractFields.fields[typeName] || {},
72205
- object.abstractFields.fields[possible]
72440
+ object.abstractFields.fields[typeName] ?? {},
72441
+ object.abstractFields.fields[possible] ?? {}
72206
72442
  );
72207
72443
  overlap = true;
72208
72444
  }
@@ -72233,6 +72469,30 @@ function selection({
72233
72469
  }
72234
72470
  }
72235
72471
  }
72472
+ for (const [key, value] of Object.entries(object.fields ?? {})) {
72473
+ const selection = value.selection;
72474
+ if (selection) {
72475
+ mergeSelection({
72476
+ filepath,
72477
+ typeMap,
72478
+ abstractTypes,
72479
+ object: selection
72480
+ });
72481
+ }
72482
+ }
72483
+ for (const [type, selection] of Object.entries(object.abstractFields?.fields ?? {})) {
72484
+ for (const [key, value] of Object.entries(selection ?? {})) {
72485
+ const selection2 = value.selection;
72486
+ if (selection2) {
72487
+ mergeSelection({
72488
+ filepath,
72489
+ typeMap,
72490
+ abstractTypes,
72491
+ object: selection2
72492
+ });
72493
+ }
72494
+ }
72495
+ }
72236
72496
  return object;
72237
72497
  }
72238
72498
 
@@ -72297,7 +72557,12 @@ function artifactGenerator(stats) {
72297
72557
  writeIndexFile(config4, docs)
72298
72558
  ].concat(
72299
72559
  docs.map(async (doc) => {
72300
- const { document, name, generateArtifact } = doc;
72560
+ const {
72561
+ document,
72562
+ name,
72563
+ generateArtifact,
72564
+ originalParsed
72565
+ } = doc;
72301
72566
  if (!generateArtifact) {
72302
72567
  return;
72303
72568
  }
@@ -72336,6 +72601,16 @@ function artifactGenerator(stats) {
72336
72601
  );
72337
72602
  let rootType = "";
72338
72603
  let selectionSet;
72604
+ let originalSelectionSet = null;
72605
+ const fragmentDefinitions = doc.document.definitions.filter(
72606
+ (definition) => definition.kind === "FragmentDefinition"
72607
+ ).reduce(
72608
+ (prev, definition) => ({
72609
+ ...prev,
72610
+ [definition.name.value]: definition
72611
+ }),
72612
+ {}
72613
+ );
72339
72614
  if (docKind !== ArtifactKind.Fragment) {
72340
72615
  const operation = operations[0];
72341
72616
  if (operation.operation === "query") {
@@ -72352,9 +72627,12 @@ function artifactGenerator(stats) {
72352
72627
  });
72353
72628
  }
72354
72629
  selectionSet = operation.selectionSet;
72630
+ if (originalParsed.definitions[0].kind === "OperationDefinition") {
72631
+ originalSelectionSet = originalParsed.definitions[0].selectionSet;
72632
+ }
72355
72633
  } else {
72356
72634
  const matchingFragment = fragments.find(
72357
- (fragment) => fragment.name.value === name
72635
+ (fragment2) => fragment2.name.value === name
72358
72636
  );
72359
72637
  if (!matchingFragment) {
72360
72638
  throw new HoudiniError({
@@ -72364,6 +72642,12 @@ function artifactGenerator(stats) {
72364
72642
  }
72365
72643
  rootType = matchingFragment.typeCondition.name.value;
72366
72644
  selectionSet = matchingFragment.selectionSet;
72645
+ if (originalParsed.definitions[0].kind === "FragmentDefinition") {
72646
+ originalSelectionSet = originalParsed.definitions[0].selectionSet;
72647
+ }
72648
+ }
72649
+ if (!originalSelectionSet) {
72650
+ throw new Error("Not original selection set!");
72367
72651
  }
72368
72652
  let inputs = operations[0]?.variableDefinitions;
72369
72653
  let directive = fragments[0]?.directives?.find(
@@ -72372,21 +72656,18 @@ function artifactGenerator(stats) {
72372
72656
  if (docKind === ArtifactKind.Fragment && directive) {
72373
72657
  inputs = fragmentArgumentsDefinitions(config4, doc.filename, fragments[0]);
72374
72658
  }
72375
- const mergedSelection = flattenSelections({
72659
+ const mask = selection_default({
72376
72660
  config: config4,
72377
72661
  filepath: doc.filename,
72378
- selections: selectionSet.selections,
72379
- fragmentDefinitions: doc.document.definitions.filter(
72380
- (definition) => definition.kind === "FragmentDefinition"
72381
- ).reduce(
72382
- (prev, definition) => ({
72383
- ...prev,
72384
- [definition.name.value]: definition
72385
- }),
72386
- {}
72387
- ),
72388
- ignoreMaskDisable: docKind === "HoudiniQuery",
72389
- applyFragments: docKind !== "HoudiniFragment"
72662
+ rootType,
72663
+ operations: {},
72664
+ document: doc,
72665
+ selections: flattenSelections({
72666
+ config: config4,
72667
+ filepath: doc.filename,
72668
+ selections: selectionSet.selections,
72669
+ fragmentDefinitions
72670
+ })
72390
72671
  });
72391
72672
  let artifact = {
72392
72673
  name,
@@ -72395,21 +72676,29 @@ function artifactGenerator(stats) {
72395
72676
  refetch: doc.refetch,
72396
72677
  raw: rawString,
72397
72678
  rootType,
72398
- selection: selection({
72679
+ selection: selection_default({
72399
72680
  config: config4,
72400
72681
  filepath: doc.filename,
72401
72682
  rootType,
72402
- selections: mergedSelection,
72683
+ selections: flattenSelections({
72684
+ config: config4,
72685
+ filepath: doc.filename,
72686
+ selections: selectionSet.selections,
72687
+ fragmentDefinitions,
72688
+ ignoreMaskDisable: docKind !== "HoudiniFragment",
72689
+ keepFragmentSpreadNodes: true
72690
+ }),
72403
72691
  operations: operationsByPath(
72404
72692
  config4,
72405
72693
  doc.filename,
72406
72694
  operations[0],
72407
72695
  filterTypes
72408
72696
  ),
72409
- includeFragments: docKind !== "HoudiniFragment",
72410
72697
  document: doc
72411
- })
72698
+ }),
72699
+ pluginData: {}
72412
72700
  };
72701
+ applyMask(config4, artifact.selection, mask);
72413
72702
  artifact.pluginData = {};
72414
72703
  for (const plugin2 of config4.plugins) {
72415
72704
  if (!plugin2.artifactData) {
@@ -72486,6 +72775,49 @@ function artifactGenerator(stats) {
72486
72775
  stats.deleted = await cleanupFiles(config4.artifactDirectory, listOfArtifacts);
72487
72776
  };
72488
72777
  }
72778
+ function applyMask(config4, target, mask) {
72779
+ for (const [fieldName, value] of Object.entries(mask.fields ?? {})) {
72780
+ const targetSelection = target.fields?.[fieldName];
72781
+ if (!targetSelection || !mask.fields) {
72782
+ continue;
72783
+ }
72784
+ targetSelection.visible = true;
72785
+ if (targetSelection.selection && value.selection) {
72786
+ applyMask(config4, targetSelection.selection, value.selection);
72787
+ }
72788
+ }
72789
+ for (const [type, selection] of Object.entries(mask.abstractFields?.fields ?? {})) {
72790
+ if (!selection) {
72791
+ continue;
72792
+ }
72793
+ if (target.abstractFields?.fields[type]) {
72794
+ applyMask(config4, { fields: target.abstractFields.fields[type] }, { fields: selection });
72795
+ }
72796
+ const targetType = config4.schema.getType(type);
72797
+ if (!targetType) {
72798
+ continue;
72799
+ }
72800
+ if (graphql14.isAbstractType(targetType)) {
72801
+ for (const possible of config4.schema.getPossibleTypes(targetType)) {
72802
+ if (target.abstractFields?.fields[possible.name]) {
72803
+ applyMask(
72804
+ config4,
72805
+ { fields: target.abstractFields.fields[possible.name] },
72806
+ { fields: selection }
72807
+ );
72808
+ }
72809
+ }
72810
+ }
72811
+ const mappedType = target.abstractFields?.typeMap[type];
72812
+ if (target.abstractFields && mappedType && target.abstractFields.fields[mappedType]) {
72813
+ applyMask(
72814
+ config4,
72815
+ { fields: target.abstractFields.fields[mappedType] },
72816
+ { fields: selection }
72817
+ );
72818
+ }
72819
+ }
72820
+ }
72489
72821
 
72490
72822
  // src/codegen/generators/runtime/graphqlFunction.ts
72491
72823
  var recast6 = __toESM(require_main2(), 1);
@@ -72811,7 +73143,7 @@ function addReferencedInputTypes(config4, filepath, body, visitedTypes, missingS
72811
73143
  var graphql18 = __toESM(require_graphql2(), 1);
72812
73144
  var recast10 = __toESM(require_main2(), 1);
72813
73145
  var AST10 = recast10.types.builders;
72814
- var fragmentKey = "$fragments";
73146
+ var fragmentKey2 = " $fragments";
72815
73147
  function inlineType({
72816
73148
  config: config4,
72817
73149
  filepath,
@@ -72851,24 +73183,24 @@ function inlineType({
72851
73183
  const rootObj = type;
72852
73184
  const inlineFragments = {};
72853
73185
  const selectedFields = [];
72854
- for (const selection2 of selections) {
72855
- if (selection2.kind === "InlineFragment" && selection2.typeCondition) {
72856
- const fragmentType = config4.schema.getType(selection2.typeCondition.name.value);
73186
+ for (const selection of selections) {
73187
+ if (selection.kind === "InlineFragment" && selection.typeCondition) {
73188
+ const fragmentType = config4.schema.getType(selection.typeCondition.name.value);
72857
73189
  if (!graphql18.isInterfaceType(type) && !graphql18.isUnionType(type)) {
72858
- selectedFields.push(...selection2.selectionSet.selections);
73190
+ selectedFields.push(...selection.selectionSet.selections);
72859
73191
  continue;
72860
73192
  }
72861
73193
  if (!graphql18.isInterfaceType(fragmentType) && !graphql18.isUnionType(fragmentType)) {
72862
73194
  if (!inlineFragments[fragmentType.name]) {
72863
73195
  inlineFragments[fragmentType.name] = [];
72864
73196
  }
72865
- inlineFragments[fragmentType.name].push(...selection2.selectionSet.selections);
73197
+ inlineFragments[fragmentType.name].push(...selection.selectionSet.selections);
72866
73198
  continue;
72867
73199
  }
72868
73200
  const possibleParents = config4.schema.getPossibleTypes(type).map((t2) => t2.name);
72869
73201
  const freeSelections = [];
72870
73202
  const typeSpecificSelections = {};
72871
- for (const node of selection2.selectionSet.selections) {
73203
+ for (const node of selection.selectionSet.selections) {
72872
73204
  if (node.kind !== "InlineFragment") {
72873
73205
  freeSelections.push(node);
72874
73206
  } else if (node.typeCondition) {
@@ -72891,23 +73223,30 @@ function inlineType({
72891
73223
  );
72892
73224
  }
72893
73225
  }
72894
- } else if (selection2.kind === "InlineFragment" && !selection2.typeCondition) {
72895
- selectedFields.push(...selection2.selectionSet.selections);
73226
+ } else if (selection.kind === "InlineFragment" && !selection.typeCondition) {
73227
+ selectedFields.push(...selection.selectionSet.selections);
72896
73228
  } else {
72897
- selectedFields.push(selection2);
73229
+ selectedFields.push(selection);
72898
73230
  }
72899
73231
  }
73232
+ const fields = Object.values(
73233
+ selectedFields.filter((field) => field.kind === "Field").reduce(
73234
+ (sel, field) => ({
73235
+ ...sel,
73236
+ [field.alias?.value ?? field.name.value]: field
73237
+ }),
73238
+ {}
73239
+ )
73240
+ );
72900
73241
  result = AST10.tsTypeLiteral([
72901
- ...(selectedFields || []).filter(
72902
- (field) => field.kind === "Field"
72903
- ).map((selection2) => {
72904
- const { field } = selectionTypeInfo(config4.schema, filepath, rootObj, selection2);
72905
- const attributeName = selection2.alias?.value || selection2.name.value;
73242
+ ...fields.map((selection) => {
73243
+ const { field } = selectionTypeInfo(config4.schema, filepath, rootObj, selection);
73244
+ const attributeName = selection.alias?.value || selection.name.value;
72906
73245
  let attributeType = inlineType({
72907
73246
  config: config4,
72908
73247
  filepath,
72909
73248
  rootType: field.type,
72910
- selections: selection2.selectionSet?.selections,
73249
+ selections: selection.selectionSet?.selections,
72911
73250
  root: false,
72912
73251
  allowReadonly,
72913
73252
  visitedTypes,
@@ -72916,7 +73255,7 @@ function inlineType({
72916
73255
  includeFragments,
72917
73256
  allOptional
72918
73257
  });
72919
- const hasIncludeOrSkipDirective = selection2.directives && selection2.directives.filter(
73258
+ const hasIncludeOrSkipDirective = selection.directives && selection.directives.filter(
72920
73259
  (directive) => directive.name.value === "include" || directive.name.value === "skip"
72921
73260
  ).length > 0;
72922
73261
  if (hasIncludeOrSkipDirective) {
@@ -72940,15 +73279,13 @@ function inlineType({
72940
73279
  result.members.push(
72941
73280
  readonlyProperty(
72942
73281
  AST10.tsPropertySignature(
72943
- AST10.identifier(fragmentKey),
73282
+ AST10.stringLiteral(fragmentKey2),
72944
73283
  AST10.tsTypeAnnotation(
72945
73284
  AST10.tsTypeLiteral(
72946
73285
  (fragmentSpreads || []).map(
72947
73286
  (fragmentSpread) => AST10.tsPropertySignature(
72948
73287
  AST10.identifier(fragmentSpread.name.value),
72949
- AST10.tsTypeAnnotation(
72950
- AST10.tsLiteralType(AST10.booleanLiteral(true))
72951
- )
73288
+ AST10.tsTypeAnnotation(AST10.tsTypeLiteral([]))
72952
73289
  )
72953
73290
  )
72954
73291
  )
@@ -72958,7 +73295,7 @@ function inlineType({
72958
73295
  )
72959
73296
  );
72960
73297
  }
72961
- const inlineFragmentSelections = Object.entries(inlineFragments).flatMap(([typeName, fragment]) => {
73298
+ const inlineFragmentSelections = Object.entries(inlineFragments).flatMap(([typeName, fragment2]) => {
72962
73299
  const fragmentRootType = config4.schema.getType(typeName);
72963
73300
  if (!fragmentRootType) {
72964
73301
  return [];
@@ -72967,7 +73304,7 @@ function inlineType({
72967
73304
  config: config4,
72968
73305
  filepath,
72969
73306
  rootType: fragmentRootType,
72970
- selections: fragment,
73307
+ selections: fragment2,
72971
73308
  allowReadonly,
72972
73309
  visitedTypes,
72973
73310
  root,
@@ -73039,10 +73376,10 @@ function inlineType({
73039
73376
  }
73040
73377
  return result;
73041
73378
  }
73042
- function selectionTypeInfo(schema, filepath, rootType, selection2) {
73043
- const selectionName = selection2.name.value;
73379
+ function selectionTypeInfo(schema, filepath, rootType, selection) {
73380
+ const selectionName = selection.name.value;
73044
73381
  let fields = {};
73045
- if (selection2.kind === "Field" && selection2.name.value === "__typename") {
73382
+ if (selection.kind === "Field" && selection.name.value === "__typename") {
73046
73383
  return {
73047
73384
  field: {
73048
73385
  name: "__typename",
@@ -73113,7 +73450,7 @@ async function generateDocumentTypes(config4, docs) {
73113
73450
  filepath: filename,
73114
73451
  selections: definition.selectionSet.selections,
73115
73452
  fragmentDefinitions,
73116
- applyFragments: definition.kind === "OperationDefinition"
73453
+ keepFragmentSpreadNodes: true
73117
73454
  });
73118
73455
  if (definition?.kind === "OperationDefinition") {
73119
73456
  await generateOperationTypeDefs(
@@ -73337,39 +73674,26 @@ async function generateFragmentTypeDefs(config4, filepath, body, selections, def
73337
73674
  if (!type) {
73338
73675
  throw new Error("Should not get here");
73339
73676
  }
73340
- let extraExports = [];
73341
73677
  let directive = definition.directives?.find(
73342
73678
  (directive2) => directive2.name.value === config4.argumentsDirective
73343
73679
  );
73344
- if (directive) {
73345
- extraExports.push(
73346
- AST11.exportNamedDeclaration(
73347
- AST11.tsTypeAliasDeclaration(
73348
- AST11.identifier(inputTypeName),
73349
- AST11.tsTypeLiteral(
73350
- (fragmentArgumentsDefinitions(config4, filepath, definition) || []).map(
73351
- (definition2) => {
73352
- return AST11.tsPropertySignature(
73353
- AST11.identifier(definition2.variable.name.value),
73354
- AST11.tsTypeAnnotation(
73355
- tsTypeReference(
73356
- config4,
73357
- missingScalars,
73358
- definition2,
73359
- body
73360
- )
73361
- ),
73362
- definition2.type.kind !== "NonNullType"
73363
- );
73364
- }
73365
- )
73366
- )
73367
- )
73368
- )
73369
- );
73370
- }
73680
+ let inputValue = !directive ? AST11.tsTypeLiteral([]) : AST11.tsTypeLiteral(
73681
+ (fragmentArgumentsDefinitions(config4, filepath, definition) || []).map(
73682
+ (definition2) => {
73683
+ return AST11.tsPropertySignature(
73684
+ AST11.identifier(definition2.variable.name.value),
73685
+ AST11.tsTypeAnnotation(
73686
+ tsTypeReference(config4, missingScalars, definition2, body)
73687
+ ),
73688
+ definition2.type.kind !== "NonNullType"
73689
+ );
73690
+ }
73691
+ )
73692
+ );
73371
73693
  body.push(
73372
- ...extraExports,
73694
+ AST11.exportNamedDeclaration(
73695
+ AST11.tsTypeAliasDeclaration(AST11.identifier(inputTypeName), inputValue)
73696
+ ),
73373
73697
  AST11.exportNamedDeclaration(
73374
73698
  AST11.tsTypeAliasDeclaration(
73375
73699
  AST11.identifier(propTypeName),
@@ -73385,14 +73709,12 @@ async function generateFragmentTypeDefs(config4, filepath, body, selections, def
73385
73709
  ),
73386
73710
  readonlyProperty(
73387
73711
  AST11.tsPropertySignature(
73388
- AST11.stringLiteral(fragmentKey),
73712
+ AST11.stringLiteral(fragmentKey2),
73389
73713
  AST11.tsTypeAnnotation(
73390
73714
  AST11.tsTypeLiteral([
73391
73715
  AST11.tsPropertySignature(
73392
73716
  AST11.stringLiteral(propTypeName),
73393
- AST11.tsTypeAnnotation(
73394
- AST11.tsLiteralType(AST11.booleanLiteral(true))
73395
- )
73717
+ AST11.tsTypeAnnotation(AST11.tsAnyKeyword())
73396
73718
  )
73397
73719
  ])
73398
73720
  )
@@ -74104,6 +74426,13 @@ async function addID(config4, documents) {
74104
74426
  return;
74105
74427
  }
74106
74428
  return addKeysToSelection(config4, node, fragmentType);
74429
+ },
74430
+ FragmentDefinition(node) {
74431
+ const fragmentType = config4.schema.getType(node.typeCondition.name.value);
74432
+ if (!fragmentType) {
74433
+ return;
74434
+ }
74435
+ return addKeysToSelection(config4, node, fragmentType);
74107
74436
  }
74108
74437
  });
74109
74438
  }
@@ -74122,7 +74451,7 @@ function addKeysToSelection(config4, node, fieldType) {
74122
74451
  const selections = [...node.selectionSet.selections];
74123
74452
  for (const keyField of keyFields) {
74124
74453
  if (node.selectionSet.selections.find(
74125
- (selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
74454
+ (selection) => selection.kind === "Field" && !selection.alias && selection.name.value === keyField
74126
74455
  )) {
74127
74456
  continue;
74128
74457
  }