houdini 1.1.1 → 1.1.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.
@@ -54808,13 +54808,23 @@ var List = class {
54808
54808
  when(when) {
54809
54809
  return this.manager.lists.get(this.name).get(this.recordID).when(when);
54810
54810
  }
54811
- append(selection, data, variables = {}) {
54812
- return this.addToList(selection, data, variables, "last");
54811
+ append({
54812
+ selection,
54813
+ data,
54814
+ variables = {},
54815
+ layer
54816
+ }) {
54817
+ return this.addToList(selection, data, variables, "last", layer);
54813
54818
  }
54814
- prepend(selection, data, variables = {}) {
54815
- return this.addToList(selection, data, variables, "first");
54819
+ prepend({
54820
+ selection,
54821
+ data,
54822
+ variables = {},
54823
+ layer
54824
+ }) {
54825
+ return this.addToList(selection, data, variables, "first", layer);
54816
54826
  }
54817
- addToList(selection, data, variables = {}, where) {
54827
+ addToList(selection, data, variables = {}, where, layer) {
54818
54828
  const listType = this.listType(data);
54819
54829
  const dataID = this.cache._internal_unstable.id(listType, data);
54820
54830
  if (!this.validateWhen() || !dataID) {
@@ -54892,7 +54902,8 @@ var List = class {
54892
54902
  data: insertData,
54893
54903
  variables,
54894
54904
  parent: this.recordID,
54895
- applyUpdates: [where === "first" ? "prepend" : "append"]
54905
+ applyUpdates: [where === "first" ? "prepend" : "append"],
54906
+ layer: layer?.id
54896
54907
  });
54897
54908
  }
54898
54909
  removeID(id, variables = {}) {
@@ -54985,9 +54996,15 @@ var List = class {
54985
54996
  }
54986
54997
  return ok;
54987
54998
  }
54988
- toggleElement(selection, data, variables = {}, where) {
54999
+ toggleElement({
55000
+ selection,
55001
+ data,
55002
+ variables = {},
55003
+ layer,
55004
+ where
55005
+ }) {
54989
55006
  if (!this.remove(data, variables)) {
54990
- this.addToList(selection, data, variables, where);
55007
+ this.addToList(selection, data, variables, where, layer);
54991
55008
  }
54992
55009
  }
54993
55010
  *[Symbol.iterator]() {
@@ -55995,6 +56012,9 @@ var CacheInternal = class {
55995
56012
  nullable,
55996
56013
  link: !!fieldSelection
55997
56014
  });
56015
+ if (value && typeof value === "object" && "__typename" in value && value["__typename"]) {
56016
+ linkedType = value["__typename"];
56017
+ }
55998
56018
  const currentSubscribers = this.subscriptions.get(parent, key);
55999
56019
  const specs = currentSubscribers.map((sub) => sub[0]);
56000
56020
  const { value: previousValue, displayLayers } = this.storage.get(parent, key);
@@ -56048,7 +56068,6 @@ var CacheInternal = class {
56048
56068
  "Encountered interface type without __typename in the payload"
56049
56069
  );
56050
56070
  }
56051
- linkedType = value.__typename;
56052
56071
  }
56053
56072
  const embedded = this.idFields(linkedType)?.filter(
56054
56073
  (field2) => typeof value[field2] === "undefined"
@@ -56204,7 +56223,8 @@ var CacheInternal = class {
56204
56223
  fieldSelection,
56205
56224
  target,
56206
56225
  variables,
56207
- operation.position || "last"
56226
+ operation.position || "last",
56227
+ layer
56208
56228
  );
56209
56229
  } else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
56210
56230
  this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
@@ -56218,12 +56238,13 @@ var CacheInternal = class {
56218
56238
  }
56219
56239
  this.cache.delete(targetID);
56220
56240
  } else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
56221
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
56222
- fieldSelection,
56223
- target,
56241
+ this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
56242
+ selection: fieldSelection,
56243
+ data: target,
56224
56244
  variables,
56225
- operation.position || "last"
56226
- );
56245
+ where: operation.position || "last",
56246
+ layer
56247
+ });
56227
56248
  }
56228
56249
  }
56229
56250
  }
@@ -56252,7 +56273,7 @@ var CacheInternal = class {
56252
56273
  ])
56253
56274
  );
56254
56275
  }
56255
- let hasData = false;
56276
+ let hasData = !!selection.fragments;
56256
56277
  let partial = false;
56257
56278
  let cascadeNull = false;
56258
56279
  let stale = false;
@@ -56467,13 +56488,12 @@ var CacheInternal = class {
56467
56488
  const embedded = this.idFields(linkedType)?.filter(
56468
56489
  (field) => typeof entry[field] === "undefined"
56469
56490
  ).length > 0;
56470
- const typename = entryObj.__typename;
56471
56491
  let innerType = linkedType;
56472
- if (abstract) {
56473
- if (!typename) {
56474
- throw new Error("Encountered interface type without __typename in the payload");
56475
- }
56492
+ const typename = entryObj.__typename;
56493
+ if (typename) {
56476
56494
  innerType = typename;
56495
+ } else if (abstract) {
56496
+ throw new Error("Encountered interface type without __typename in the payload");
56477
56497
  }
56478
56498
  if (!embedded) {
56479
56499
  const id = this.id(innerType, entry);
@@ -59872,19 +59892,6 @@ function artifactGenerator(stats) {
59872
59892
  if (docKind === ArtifactKind.Fragment && directive) {
59873
59893
  inputs = fragmentArgumentsDefinitions(config2, doc.filename, fragments[0]);
59874
59894
  }
59875
- const mask = selection_default({
59876
- config: config2,
59877
- filepath: doc.filename,
59878
- rootType,
59879
- operations: {},
59880
- document: doc,
59881
- selections: flattenSelections({
59882
- config: config2,
59883
- filepath: doc.filename,
59884
- selections: selectionSet.selections,
59885
- fragmentDefinitions
59886
- })
59887
- });
59888
59895
  let artifact = {
59889
59896
  name,
59890
59897
  kind: docKind,
@@ -59914,7 +59921,23 @@ function artifactGenerator(stats) {
59914
59921
  }),
59915
59922
  pluginData: {}
59916
59923
  };
59917
- applyMask(config2, artifact.selection, mask);
59924
+ applyMask(
59925
+ config2,
59926
+ artifact.selection,
59927
+ selection_default({
59928
+ config: config2,
59929
+ filepath: doc.filename,
59930
+ rootType,
59931
+ operations: {},
59932
+ document: doc,
59933
+ selections: flattenSelections({
59934
+ config: config2,
59935
+ filepath: doc.filename,
59936
+ selections: selectionSet.selections,
59937
+ fragmentDefinitions
59938
+ })
59939
+ })
59940
+ );
59918
59941
  artifact.pluginData = {};
59919
59942
  for (const plugin2 of config2.plugins) {
59920
59943
  if (!plugin2.artifactData) {
@@ -59992,14 +60015,21 @@ function artifactGenerator(stats) {
59992
60015
  };
59993
60016
  }
59994
60017
  function applyMask(config2, target, mask) {
60018
+ const targetFields = Object.entries(target.fields ?? {}).concat(
60019
+ Object.values(target.abstractFields?.fields ?? {}).flatMap((typeMap) => Object.entries(typeMap))
60020
+ );
59995
60021
  for (const [fieldName, value] of Object.entries(mask.fields ?? {})) {
59996
- const targetSelection = target.fields?.[fieldName];
59997
- if (!targetSelection || !mask.fields) {
59998
- continue;
59999
- }
60000
- targetSelection.visible = true;
60001
- if (targetSelection.selection && value.selection) {
60002
- applyMask(config2, targetSelection.selection, value.selection);
60022
+ for (const [potentialFieldName, targetSelection] of targetFields) {
60023
+ if (fieldName !== potentialFieldName) {
60024
+ continue;
60025
+ }
60026
+ if (!targetSelection) {
60027
+ continue;
60028
+ }
60029
+ targetSelection.visible = true;
60030
+ if (targetSelection.selection && value.selection) {
60031
+ applyMask(config2, targetSelection.selection, value.selection);
60032
+ }
60003
60033
  }
60004
60034
  }
60005
60035
  for (const [type, selection] of Object.entries(mask.abstractFields?.fields ?? {})) {
@@ -61610,6 +61640,24 @@ async function addTypename(config2, documents) {
61610
61640
  }
61611
61641
  };
61612
61642
  }
61643
+ },
61644
+ FragmentDefinition(node) {
61645
+ return {
61646
+ ...node,
61647
+ selectionSet: {
61648
+ ...node.selectionSet,
61649
+ selections: [
61650
+ ...node.selectionSet.selections,
61651
+ {
61652
+ kind: graphql21.Kind.FIELD,
61653
+ name: {
61654
+ kind: graphql21.Kind.NAME,
61655
+ value: "__typename"
61656
+ }
61657
+ }
61658
+ ]
61659
+ }
61660
+ };
61613
61661
  }
61614
61662
  });
61615
61663
  }
@@ -62767,6 +62815,7 @@ function testConfigFile({ plugins, ...config2 } = {}) {
62767
62815
  node(id: ID!): Node
62768
62816
  customIdList: [CustomIdType]!
62769
62817
  nodes(ids: [ID!]!): [Node!]!
62818
+ monkeys: MonkeyConnection!
62770
62819
  }
62771
62820
 
62772
62821
  type PageInfo {
@@ -62847,6 +62896,37 @@ function testConfigFile({ plugins, ...config2 } = {}) {
62847
62896
  interface IsGhost {
62848
62897
  aka: String!
62849
62898
  }
62899
+
62900
+ interface Animal implements Node {
62901
+ id: ID!
62902
+ name: String!
62903
+ }
62904
+
62905
+ type Monkey implements Node & Animal {
62906
+ id: ID!
62907
+ name: String!
62908
+ hasBanana: Boolean!
62909
+ }
62910
+
62911
+ interface AnimalConnection {
62912
+ edges: [AnimalEdge!]!
62913
+ pageInfo: PageInfo!
62914
+ }
62915
+
62916
+ interface AnimalEdge {
62917
+ cursor: String
62918
+ node: Animal
62919
+ }
62920
+
62921
+ type MonkeyConnection implements AnimalConnection {
62922
+ edges: [MonkeyEdge!]!
62923
+ pageInfo: PageInfo!
62924
+ }
62925
+
62926
+ type MonkeyEdge implements AnimalEdge {
62927
+ cursor: String
62928
+ node: Monkey
62929
+ }
62850
62930
 
62851
62931
  union Entity = User | Cat | Ghost
62852
62932
 
@@ -54804,13 +54804,23 @@ var List = class {
54804
54804
  when(when) {
54805
54805
  return this.manager.lists.get(this.name).get(this.recordID).when(when);
54806
54806
  }
54807
- append(selection, data, variables = {}) {
54808
- return this.addToList(selection, data, variables, "last");
54807
+ append({
54808
+ selection,
54809
+ data,
54810
+ variables = {},
54811
+ layer
54812
+ }) {
54813
+ return this.addToList(selection, data, variables, "last", layer);
54809
54814
  }
54810
- prepend(selection, data, variables = {}) {
54811
- return this.addToList(selection, data, variables, "first");
54815
+ prepend({
54816
+ selection,
54817
+ data,
54818
+ variables = {},
54819
+ layer
54820
+ }) {
54821
+ return this.addToList(selection, data, variables, "first", layer);
54812
54822
  }
54813
- addToList(selection, data, variables = {}, where) {
54823
+ addToList(selection, data, variables = {}, where, layer) {
54814
54824
  const listType = this.listType(data);
54815
54825
  const dataID = this.cache._internal_unstable.id(listType, data);
54816
54826
  if (!this.validateWhen() || !dataID) {
@@ -54888,7 +54898,8 @@ var List = class {
54888
54898
  data: insertData,
54889
54899
  variables,
54890
54900
  parent: this.recordID,
54891
- applyUpdates: [where === "first" ? "prepend" : "append"]
54901
+ applyUpdates: [where === "first" ? "prepend" : "append"],
54902
+ layer: layer?.id
54892
54903
  });
54893
54904
  }
54894
54905
  removeID(id, variables = {}) {
@@ -54981,9 +54992,15 @@ var List = class {
54981
54992
  }
54982
54993
  return ok;
54983
54994
  }
54984
- toggleElement(selection, data, variables = {}, where) {
54995
+ toggleElement({
54996
+ selection,
54997
+ data,
54998
+ variables = {},
54999
+ layer,
55000
+ where
55001
+ }) {
54985
55002
  if (!this.remove(data, variables)) {
54986
- this.addToList(selection, data, variables, where);
55003
+ this.addToList(selection, data, variables, where, layer);
54987
55004
  }
54988
55005
  }
54989
55006
  *[Symbol.iterator]() {
@@ -55991,6 +56008,9 @@ var CacheInternal = class {
55991
56008
  nullable,
55992
56009
  link: !!fieldSelection
55993
56010
  });
56011
+ if (value && typeof value === "object" && "__typename" in value && value["__typename"]) {
56012
+ linkedType = value["__typename"];
56013
+ }
55994
56014
  const currentSubscribers = this.subscriptions.get(parent, key);
55995
56015
  const specs = currentSubscribers.map((sub) => sub[0]);
55996
56016
  const { value: previousValue, displayLayers } = this.storage.get(parent, key);
@@ -56044,7 +56064,6 @@ var CacheInternal = class {
56044
56064
  "Encountered interface type without __typename in the payload"
56045
56065
  );
56046
56066
  }
56047
- linkedType = value.__typename;
56048
56067
  }
56049
56068
  const embedded = this.idFields(linkedType)?.filter(
56050
56069
  (field2) => typeof value[field2] === "undefined"
@@ -56200,7 +56219,8 @@ var CacheInternal = class {
56200
56219
  fieldSelection,
56201
56220
  target,
56202
56221
  variables,
56203
- operation.position || "last"
56222
+ operation.position || "last",
56223
+ layer
56204
56224
  );
56205
56225
  } else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
56206
56226
  this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
@@ -56214,12 +56234,13 @@ var CacheInternal = class {
56214
56234
  }
56215
56235
  this.cache.delete(targetID);
56216
56236
  } else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
56217
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
56218
- fieldSelection,
56219
- target,
56237
+ this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
56238
+ selection: fieldSelection,
56239
+ data: target,
56220
56240
  variables,
56221
- operation.position || "last"
56222
- );
56241
+ where: operation.position || "last",
56242
+ layer
56243
+ });
56223
56244
  }
56224
56245
  }
56225
56246
  }
@@ -56248,7 +56269,7 @@ var CacheInternal = class {
56248
56269
  ])
56249
56270
  );
56250
56271
  }
56251
- let hasData = false;
56272
+ let hasData = !!selection.fragments;
56252
56273
  let partial = false;
56253
56274
  let cascadeNull = false;
56254
56275
  let stale = false;
@@ -56463,13 +56484,12 @@ var CacheInternal = class {
56463
56484
  const embedded = this.idFields(linkedType)?.filter(
56464
56485
  (field) => typeof entry[field] === "undefined"
56465
56486
  ).length > 0;
56466
- const typename = entryObj.__typename;
56467
56487
  let innerType = linkedType;
56468
- if (abstract) {
56469
- if (!typename) {
56470
- throw new Error("Encountered interface type without __typename in the payload");
56471
- }
56488
+ const typename = entryObj.__typename;
56489
+ if (typename) {
56472
56490
  innerType = typename;
56491
+ } else if (abstract) {
56492
+ throw new Error("Encountered interface type without __typename in the payload");
56473
56493
  }
56474
56494
  if (!embedded) {
56475
56495
  const id = this.id(innerType, entry);
@@ -59867,19 +59887,6 @@ function artifactGenerator(stats) {
59867
59887
  if (docKind === ArtifactKind.Fragment && directive) {
59868
59888
  inputs = fragmentArgumentsDefinitions(config2, doc.filename, fragments[0]);
59869
59889
  }
59870
- const mask = selection_default({
59871
- config: config2,
59872
- filepath: doc.filename,
59873
- rootType,
59874
- operations: {},
59875
- document: doc,
59876
- selections: flattenSelections({
59877
- config: config2,
59878
- filepath: doc.filename,
59879
- selections: selectionSet.selections,
59880
- fragmentDefinitions
59881
- })
59882
- });
59883
59890
  let artifact = {
59884
59891
  name,
59885
59892
  kind: docKind,
@@ -59909,7 +59916,23 @@ function artifactGenerator(stats) {
59909
59916
  }),
59910
59917
  pluginData: {}
59911
59918
  };
59912
- applyMask(config2, artifact.selection, mask);
59919
+ applyMask(
59920
+ config2,
59921
+ artifact.selection,
59922
+ selection_default({
59923
+ config: config2,
59924
+ filepath: doc.filename,
59925
+ rootType,
59926
+ operations: {},
59927
+ document: doc,
59928
+ selections: flattenSelections({
59929
+ config: config2,
59930
+ filepath: doc.filename,
59931
+ selections: selectionSet.selections,
59932
+ fragmentDefinitions
59933
+ })
59934
+ })
59935
+ );
59913
59936
  artifact.pluginData = {};
59914
59937
  for (const plugin2 of config2.plugins) {
59915
59938
  if (!plugin2.artifactData) {
@@ -59987,14 +60010,21 @@ function artifactGenerator(stats) {
59987
60010
  };
59988
60011
  }
59989
60012
  function applyMask(config2, target, mask) {
60013
+ const targetFields = Object.entries(target.fields ?? {}).concat(
60014
+ Object.values(target.abstractFields?.fields ?? {}).flatMap((typeMap) => Object.entries(typeMap))
60015
+ );
59990
60016
  for (const [fieldName, value] of Object.entries(mask.fields ?? {})) {
59991
- const targetSelection = target.fields?.[fieldName];
59992
- if (!targetSelection || !mask.fields) {
59993
- continue;
59994
- }
59995
- targetSelection.visible = true;
59996
- if (targetSelection.selection && value.selection) {
59997
- applyMask(config2, targetSelection.selection, value.selection);
60017
+ for (const [potentialFieldName, targetSelection] of targetFields) {
60018
+ if (fieldName !== potentialFieldName) {
60019
+ continue;
60020
+ }
60021
+ if (!targetSelection) {
60022
+ continue;
60023
+ }
60024
+ targetSelection.visible = true;
60025
+ if (targetSelection.selection && value.selection) {
60026
+ applyMask(config2, targetSelection.selection, value.selection);
60027
+ }
59998
60028
  }
59999
60029
  }
60000
60030
  for (const [type, selection] of Object.entries(mask.abstractFields?.fields ?? {})) {
@@ -61605,6 +61635,24 @@ async function addTypename(config2, documents) {
61605
61635
  }
61606
61636
  };
61607
61637
  }
61638
+ },
61639
+ FragmentDefinition(node) {
61640
+ return {
61641
+ ...node,
61642
+ selectionSet: {
61643
+ ...node.selectionSet,
61644
+ selections: [
61645
+ ...node.selectionSet.selections,
61646
+ {
61647
+ kind: graphql21.Kind.FIELD,
61648
+ name: {
61649
+ kind: graphql21.Kind.NAME,
61650
+ value: "__typename"
61651
+ }
61652
+ }
61653
+ ]
61654
+ }
61655
+ };
61608
61656
  }
61609
61657
  });
61610
61658
  }
@@ -62762,6 +62810,7 @@ function testConfigFile({ plugins, ...config2 } = {}) {
62762
62810
  node(id: ID!): Node
62763
62811
  customIdList: [CustomIdType]!
62764
62812
  nodes(ids: [ID!]!): [Node!]!
62813
+ monkeys: MonkeyConnection!
62765
62814
  }
62766
62815
 
62767
62816
  type PageInfo {
@@ -62842,6 +62891,37 @@ function testConfigFile({ plugins, ...config2 } = {}) {
62842
62891
  interface IsGhost {
62843
62892
  aka: String!
62844
62893
  }
62894
+
62895
+ interface Animal implements Node {
62896
+ id: ID!
62897
+ name: String!
62898
+ }
62899
+
62900
+ type Monkey implements Node & Animal {
62901
+ id: ID!
62902
+ name: String!
62903
+ hasBanana: Boolean!
62904
+ }
62905
+
62906
+ interface AnimalConnection {
62907
+ edges: [AnimalEdge!]!
62908
+ pageInfo: PageInfo!
62909
+ }
62910
+
62911
+ interface AnimalEdge {
62912
+ cursor: String
62913
+ node: Animal
62914
+ }
62915
+
62916
+ type MonkeyConnection implements AnimalConnection {
62917
+ edges: [MonkeyEdge!]!
62918
+ pageInfo: PageInfo!
62919
+ }
62920
+
62921
+ type MonkeyEdge implements AnimalEdge {
62922
+ cursor: String
62923
+ node: Monkey
62924
+ }
62845
62925
 
62846
62926
  union Entity = User | Cat | Ghost
62847
62927