houdini 1.2.1 → 1.2.2

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.
@@ -57283,18 +57283,14 @@ function flattenSelections({
57283
57283
  filepath,
57284
57284
  selections,
57285
57285
  fragmentDefinitions,
57286
- ignoreMaskDisable,
57287
- keepFragmentSpreadNodes,
57288
- hoistFragments
57286
+ applyFragments
57289
57287
  }) {
57290
57288
  const fields = new FieldCollection({
57291
57289
  config: config2,
57292
57290
  filepath,
57293
57291
  selections,
57294
57292
  fragmentDefinitions,
57295
- ignoreMaskDisable: !!ignoreMaskDisable,
57296
- keepFragmentSpreadNodes: !!keepFragmentSpreadNodes,
57297
- hoistFragments
57293
+ applyFragments: !!applyFragments
57298
57294
  });
57299
57295
  return fields.toSelectionSet();
57300
57296
  }
@@ -57305,18 +57301,14 @@ var FieldCollection = class {
57305
57301
  fields;
57306
57302
  inlineFragments;
57307
57303
  fragmentSpreads;
57308
- ignoreMaskDisable;
57309
- keepFragmentSpreadNodes;
57310
- hoistFragments;
57304
+ applyFragments;
57311
57305
  constructor(args) {
57312
57306
  this.config = args.config;
57313
57307
  this.fragmentDefinitions = args.fragmentDefinitions;
57314
- this.ignoreMaskDisable = args.ignoreMaskDisable;
57315
- this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
57308
+ this.applyFragments = args.applyFragments;
57316
57309
  this.fields = {};
57317
57310
  this.inlineFragments = {};
57318
57311
  this.fragmentSpreads = {};
57319
- this.hoistFragments = !!args.hoistFragments;
57320
57312
  this.filepath = args.filepath;
57321
57313
  for (const selection of args.selections) {
57322
57314
  this.add({ selection });
@@ -57326,21 +57318,18 @@ var FieldCollection = class {
57326
57318
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
57327
57319
  }
57328
57320
  add({ selection, external }) {
57329
- let includeFragments = this.config.defaultFragmentMasking === "disable";
57321
+ let include = this.config.defaultFragmentMasking === "disable";
57330
57322
  const maskEnableDirective = selection.directives?.find(
57331
57323
  ({ name }) => name.value === this.config.maskEnableDirective
57332
57324
  );
57333
57325
  if (maskEnableDirective) {
57334
- includeFragments = false;
57326
+ include = false;
57335
57327
  }
57336
57328
  const maskDisableDirective = selection.directives?.find(
57337
57329
  ({ name }) => name.value === this.config.maskDisableDirective
57338
57330
  );
57339
57331
  if (maskDisableDirective) {
57340
- includeFragments = true;
57341
- }
57342
- if (this.ignoreMaskDisable) {
57343
- includeFragments = true;
57332
+ include = true;
57344
57333
  }
57345
57334
  if (selection.kind === "Field") {
57346
57335
  const key = selection.alias?.value || selection.name.value;
@@ -57356,7 +57345,7 @@ var FieldCollection = class {
57356
57345
  external
57357
57346
  });
57358
57347
  }
57359
- if (!external && includeFragments) {
57348
+ if (this.applyFragments && !external) {
57360
57349
  this.fields[key].selection.fragmentSpreads = {
57361
57350
  ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
57362
57351
  ...this.fields[key].selection.fragmentSpreads
@@ -57370,16 +57359,13 @@ var FieldCollection = class {
57370
57359
  }
57371
57360
  }
57372
57361
  if (selection.kind === "InlineFragment" && selection.typeCondition) {
57373
- this.walkInlineFragment({ selection, external, hoistFragments: this.hoistFragments });
57362
+ this.walkInlineFragment({ selection, external });
57374
57363
  return;
57375
57364
  }
57376
57365
  if (selection.kind === "FragmentSpread") {
57377
- if (this.keepFragmentSpreadNodes && !external) {
57366
+ if (!external || include) {
57378
57367
  this.fragmentSpreads[selection.name.value] = selection;
57379
57368
  }
57380
- if (!includeFragments) {
57381
- return;
57382
- }
57383
57369
  const definition = this.fragmentDefinitions[selection.name.value];
57384
57370
  if (!definition) {
57385
57371
  throw new HoudiniError({
@@ -57387,23 +57373,25 @@ var FieldCollection = class {
57387
57373
  message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
57388
57374
  });
57389
57375
  }
57390
- this.add({
57391
- selection: {
57392
- kind: "InlineFragment",
57393
- typeCondition: {
57394
- kind: "NamedType",
57395
- name: {
57396
- kind: "Name",
57397
- value: definition.typeCondition.name.value
57376
+ if (this.applyFragments || include) {
57377
+ this.add({
57378
+ selection: {
57379
+ kind: "InlineFragment",
57380
+ typeCondition: {
57381
+ kind: "NamedType",
57382
+ name: {
57383
+ kind: "Name",
57384
+ value: definition.typeCondition.name.value
57385
+ }
57386
+ },
57387
+ selectionSet: {
57388
+ kind: "SelectionSet",
57389
+ selections: [...definition.selectionSet.selections]
57398
57390
  }
57399
57391
  },
57400
- selectionSet: {
57401
- kind: "SelectionSet",
57402
- selections: [...definition.selectionSet.selections]
57403
- }
57404
- },
57405
- external
57406
- });
57392
+ external: !include
57393
+ });
57394
+ }
57407
57395
  }
57408
57396
  }
57409
57397
  collectFragmentSpreads(selections, result = {}) {
@@ -57460,8 +57448,7 @@ var FieldCollection = class {
57460
57448
  }
57461
57449
  walkInlineFragment({
57462
57450
  selection,
57463
- external,
57464
- hoistFragments
57451
+ external
57465
57452
  }) {
57466
57453
  const key = selection.typeCondition.name.value;
57467
57454
  if (!this.inlineFragments[key]) {
@@ -57471,7 +57458,7 @@ var FieldCollection = class {
57471
57458
  };
57472
57459
  }
57473
57460
  for (const subselect of selection.selectionSet.selections || []) {
57474
- if (subselect.kind === "FragmentSpread" && !hoistFragments || subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
57461
+ if (subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
57475
57462
  this.inlineFragments[key].selection.add({
57476
57463
  selection: subselect,
57477
57464
  external
@@ -57480,11 +57467,11 @@ var FieldCollection = class {
57480
57467
  } else if (subselect.kind === "FragmentSpread") {
57481
57468
  this.add({
57482
57469
  selection: subselect,
57483
- external: true
57470
+ external
57484
57471
  });
57485
57472
  continue;
57486
57473
  } else {
57487
- this.walkInlineFragment({ selection: subselect, external, hoistFragments });
57474
+ this.walkInlineFragment({ selection: subselect, external });
57488
57475
  }
57489
57476
  }
57490
57477
  }
@@ -57494,9 +57481,7 @@ var FieldCollection = class {
57494
57481
  fragmentDefinitions: this.fragmentDefinitions,
57495
57482
  selections: [],
57496
57483
  filepath: this.filepath,
57497
- ignoreMaskDisable: this.ignoreMaskDisable,
57498
- keepFragmentSpreadNodes: this.keepFragmentSpreadNodes,
57499
- hoistFragments: this.hoistFragments
57484
+ applyFragments: this.applyFragments
57500
57485
  });
57501
57486
  }
57502
57487
  };
@@ -59416,7 +59401,8 @@ function prepareSelection({
59416
59401
  inConnection,
59417
59402
  typeMap,
59418
59403
  abstractTypes,
59419
- globalLoading
59404
+ globalLoading,
59405
+ includeFragments
59420
59406
  }) {
59421
59407
  let object = {};
59422
59408
  const loadingTypes = [];
@@ -59436,7 +59422,8 @@ function prepareSelection({
59436
59422
  document,
59437
59423
  typeMap,
59438
59424
  abstractTypes,
59439
- globalLoading
59425
+ globalLoading,
59426
+ includeFragments
59440
59427
  }).fields || {}
59441
59428
  );
59442
59429
  } else {
@@ -59484,7 +59471,8 @@ function prepareSelection({
59484
59471
  document,
59485
59472
  typeMap,
59486
59473
  abstractTypes,
59487
- globalLoading
59474
+ globalLoading,
59475
+ includeFragments
59488
59476
  }).fields
59489
59477
  };
59490
59478
  if (field.directives?.find((d) => d.name.value === config2.loadingDirective)) {
@@ -59602,7 +59590,8 @@ function prepareSelection({
59602
59590
  inConnection: connectionState,
59603
59591
  typeMap,
59604
59592
  abstractTypes,
59605
- globalLoading: forceLoading
59593
+ globalLoading: forceLoading,
59594
+ includeFragments
59606
59595
  });
59607
59596
  if (Object.values(fieldObj.selection.fields ?? {}).some((field2) => field2.required)) {
59608
59597
  fieldObj.nullable = true;
@@ -59935,14 +59924,13 @@ function artifactGenerator(stats) {
59935
59924
  document: doc,
59936
59925
  rootType,
59937
59926
  globalLoading,
59927
+ includeFragments: doc.kind !== ArtifactKind.Fragment,
59938
59928
  selections: flattenSelections({
59939
59929
  config: config2,
59940
59930
  filepath: doc.filename,
59941
59931
  selections: selectionSet.selections,
59942
59932
  fragmentDefinitions,
59943
- ignoreMaskDisable: docKind !== "HoudiniFragment",
59944
- keepFragmentSpreadNodes: true,
59945
- hoistFragments: true
59933
+ applyFragments: doc.kind !== ArtifactKind.Fragment
59946
59934
  }),
59947
59935
  operations: operationsByPath(
59948
59936
  config2,
@@ -60907,8 +60895,7 @@ async function generateDocumentTypes(config2, docs) {
60907
60895
  config: config2,
60908
60896
  filepath: filename,
60909
60897
  selections: definition.selectionSet.selections,
60910
- fragmentDefinitions,
60911
- keepFragmentSpreadNodes: true
60898
+ fragmentDefinitions
60912
60899
  });
60913
60900
  if (definition?.kind === "OperationDefinition") {
60914
60901
  await generateOperationTypeDefs(
@@ -57281,18 +57281,14 @@ function flattenSelections({
57281
57281
  filepath,
57282
57282
  selections,
57283
57283
  fragmentDefinitions,
57284
- ignoreMaskDisable,
57285
- keepFragmentSpreadNodes,
57286
- hoistFragments
57284
+ applyFragments
57287
57285
  }) {
57288
57286
  const fields = new FieldCollection({
57289
57287
  config: config2,
57290
57288
  filepath,
57291
57289
  selections,
57292
57290
  fragmentDefinitions,
57293
- ignoreMaskDisable: !!ignoreMaskDisable,
57294
- keepFragmentSpreadNodes: !!keepFragmentSpreadNodes,
57295
- hoistFragments
57291
+ applyFragments: !!applyFragments
57296
57292
  });
57297
57293
  return fields.toSelectionSet();
57298
57294
  }
@@ -57303,18 +57299,14 @@ var FieldCollection = class {
57303
57299
  fields;
57304
57300
  inlineFragments;
57305
57301
  fragmentSpreads;
57306
- ignoreMaskDisable;
57307
- keepFragmentSpreadNodes;
57308
- hoistFragments;
57302
+ applyFragments;
57309
57303
  constructor(args) {
57310
57304
  this.config = args.config;
57311
57305
  this.fragmentDefinitions = args.fragmentDefinitions;
57312
- this.ignoreMaskDisable = args.ignoreMaskDisable;
57313
- this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
57306
+ this.applyFragments = args.applyFragments;
57314
57307
  this.fields = {};
57315
57308
  this.inlineFragments = {};
57316
57309
  this.fragmentSpreads = {};
57317
- this.hoistFragments = !!args.hoistFragments;
57318
57310
  this.filepath = args.filepath;
57319
57311
  for (const selection of args.selections) {
57320
57312
  this.add({ selection });
@@ -57324,21 +57316,18 @@ var FieldCollection = class {
57324
57316
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
57325
57317
  }
57326
57318
  add({ selection, external }) {
57327
- let includeFragments = this.config.defaultFragmentMasking === "disable";
57319
+ let include = this.config.defaultFragmentMasking === "disable";
57328
57320
  const maskEnableDirective = selection.directives?.find(
57329
57321
  ({ name }) => name.value === this.config.maskEnableDirective
57330
57322
  );
57331
57323
  if (maskEnableDirective) {
57332
- includeFragments = false;
57324
+ include = false;
57333
57325
  }
57334
57326
  const maskDisableDirective = selection.directives?.find(
57335
57327
  ({ name }) => name.value === this.config.maskDisableDirective
57336
57328
  );
57337
57329
  if (maskDisableDirective) {
57338
- includeFragments = true;
57339
- }
57340
- if (this.ignoreMaskDisable) {
57341
- includeFragments = true;
57330
+ include = true;
57342
57331
  }
57343
57332
  if (selection.kind === "Field") {
57344
57333
  const key = selection.alias?.value || selection.name.value;
@@ -57354,7 +57343,7 @@ var FieldCollection = class {
57354
57343
  external
57355
57344
  });
57356
57345
  }
57357
- if (!external && includeFragments) {
57346
+ if (this.applyFragments && !external) {
57358
57347
  this.fields[key].selection.fragmentSpreads = {
57359
57348
  ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
57360
57349
  ...this.fields[key].selection.fragmentSpreads
@@ -57368,16 +57357,13 @@ var FieldCollection = class {
57368
57357
  }
57369
57358
  }
57370
57359
  if (selection.kind === "InlineFragment" && selection.typeCondition) {
57371
- this.walkInlineFragment({ selection, external, hoistFragments: this.hoistFragments });
57360
+ this.walkInlineFragment({ selection, external });
57372
57361
  return;
57373
57362
  }
57374
57363
  if (selection.kind === "FragmentSpread") {
57375
- if (this.keepFragmentSpreadNodes && !external) {
57364
+ if (!external || include) {
57376
57365
  this.fragmentSpreads[selection.name.value] = selection;
57377
57366
  }
57378
- if (!includeFragments) {
57379
- return;
57380
- }
57381
57367
  const definition = this.fragmentDefinitions[selection.name.value];
57382
57368
  if (!definition) {
57383
57369
  throw new HoudiniError({
@@ -57385,23 +57371,25 @@ var FieldCollection = class {
57385
57371
  message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
57386
57372
  });
57387
57373
  }
57388
- this.add({
57389
- selection: {
57390
- kind: "InlineFragment",
57391
- typeCondition: {
57392
- kind: "NamedType",
57393
- name: {
57394
- kind: "Name",
57395
- value: definition.typeCondition.name.value
57374
+ if (this.applyFragments || include) {
57375
+ this.add({
57376
+ selection: {
57377
+ kind: "InlineFragment",
57378
+ typeCondition: {
57379
+ kind: "NamedType",
57380
+ name: {
57381
+ kind: "Name",
57382
+ value: definition.typeCondition.name.value
57383
+ }
57384
+ },
57385
+ selectionSet: {
57386
+ kind: "SelectionSet",
57387
+ selections: [...definition.selectionSet.selections]
57396
57388
  }
57397
57389
  },
57398
- selectionSet: {
57399
- kind: "SelectionSet",
57400
- selections: [...definition.selectionSet.selections]
57401
- }
57402
- },
57403
- external
57404
- });
57390
+ external: !include
57391
+ });
57392
+ }
57405
57393
  }
57406
57394
  }
57407
57395
  collectFragmentSpreads(selections, result = {}) {
@@ -57458,8 +57446,7 @@ var FieldCollection = class {
57458
57446
  }
57459
57447
  walkInlineFragment({
57460
57448
  selection,
57461
- external,
57462
- hoistFragments
57449
+ external
57463
57450
  }) {
57464
57451
  const key = selection.typeCondition.name.value;
57465
57452
  if (!this.inlineFragments[key]) {
@@ -57469,7 +57456,7 @@ var FieldCollection = class {
57469
57456
  };
57470
57457
  }
57471
57458
  for (const subselect of selection.selectionSet.selections || []) {
57472
- if (subselect.kind === "FragmentSpread" && !hoistFragments || subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
57459
+ if (subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
57473
57460
  this.inlineFragments[key].selection.add({
57474
57461
  selection: subselect,
57475
57462
  external
@@ -57478,11 +57465,11 @@ var FieldCollection = class {
57478
57465
  } else if (subselect.kind === "FragmentSpread") {
57479
57466
  this.add({
57480
57467
  selection: subselect,
57481
- external: true
57468
+ external
57482
57469
  });
57483
57470
  continue;
57484
57471
  } else {
57485
- this.walkInlineFragment({ selection: subselect, external, hoistFragments });
57472
+ this.walkInlineFragment({ selection: subselect, external });
57486
57473
  }
57487
57474
  }
57488
57475
  }
@@ -57492,9 +57479,7 @@ var FieldCollection = class {
57492
57479
  fragmentDefinitions: this.fragmentDefinitions,
57493
57480
  selections: [],
57494
57481
  filepath: this.filepath,
57495
- ignoreMaskDisable: this.ignoreMaskDisable,
57496
- keepFragmentSpreadNodes: this.keepFragmentSpreadNodes,
57497
- hoistFragments: this.hoistFragments
57482
+ applyFragments: this.applyFragments
57498
57483
  });
57499
57484
  }
57500
57485
  };
@@ -59414,7 +59399,8 @@ function prepareSelection({
59414
59399
  inConnection,
59415
59400
  typeMap,
59416
59401
  abstractTypes,
59417
- globalLoading
59402
+ globalLoading,
59403
+ includeFragments
59418
59404
  }) {
59419
59405
  let object = {};
59420
59406
  const loadingTypes = [];
@@ -59434,7 +59420,8 @@ function prepareSelection({
59434
59420
  document,
59435
59421
  typeMap,
59436
59422
  abstractTypes,
59437
- globalLoading
59423
+ globalLoading,
59424
+ includeFragments
59438
59425
  }).fields || {}
59439
59426
  );
59440
59427
  } else {
@@ -59482,7 +59469,8 @@ function prepareSelection({
59482
59469
  document,
59483
59470
  typeMap,
59484
59471
  abstractTypes,
59485
- globalLoading
59472
+ globalLoading,
59473
+ includeFragments
59486
59474
  }).fields
59487
59475
  };
59488
59476
  if (field.directives?.find((d) => d.name.value === config2.loadingDirective)) {
@@ -59600,7 +59588,8 @@ function prepareSelection({
59600
59588
  inConnection: connectionState,
59601
59589
  typeMap,
59602
59590
  abstractTypes,
59603
- globalLoading: forceLoading
59591
+ globalLoading: forceLoading,
59592
+ includeFragments
59604
59593
  });
59605
59594
  if (Object.values(fieldObj.selection.fields ?? {}).some((field2) => field2.required)) {
59606
59595
  fieldObj.nullable = true;
@@ -59933,14 +59922,13 @@ function artifactGenerator(stats) {
59933
59922
  document: doc,
59934
59923
  rootType,
59935
59924
  globalLoading,
59925
+ includeFragments: doc.kind !== ArtifactKind.Fragment,
59936
59926
  selections: flattenSelections({
59937
59927
  config: config2,
59938
59928
  filepath: doc.filename,
59939
59929
  selections: selectionSet.selections,
59940
59930
  fragmentDefinitions,
59941
- ignoreMaskDisable: docKind !== "HoudiniFragment",
59942
- keepFragmentSpreadNodes: true,
59943
- hoistFragments: true
59931
+ applyFragments: doc.kind !== ArtifactKind.Fragment
59944
59932
  }),
59945
59933
  operations: operationsByPath(
59946
59934
  config2,
@@ -60905,8 +60893,7 @@ async function generateDocumentTypes(config2, docs) {
60905
60893
  config: config2,
60906
60894
  filepath: filename,
60907
60895
  selections: definition.selectionSet.selections,
60908
- fragmentDefinitions,
60909
- keepFragmentSpreadNodes: true
60896
+ fragmentDefinitions
60910
60897
  });
60911
60898
  if (definition?.kind === "OperationDefinition") {
60912
60899
  await generateOperationTypeDefs(