houdini 1.2.35 → 1.2.37

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.
@@ -1,5 +1,5 @@
1
1
  import type { ConfigFile } from '../lib/config';
2
- import type { GraphQLObject, GraphQLValue, NestedList, SubscriptionSelection, SubscriptionSpec, ValueMap } from '../lib/types';
2
+ import type { GraphQLObject, GraphQLValue, NestedList, SubscriptionSelection, SubscriptionSpec, ValueMap, ValueNode } from '../lib/types';
3
3
  import { GarbageCollector } from './gc';
4
4
  import type { ListCollection } from './lists';
5
5
  import { ListManager } from './lists';
@@ -148,9 +148,10 @@ declare class CacheInternal {
148
148
  };
149
149
  collectGarbage(): void;
150
150
  }
151
- export declare function evaluateFragmentVariables(variables: ValueMap, args: GraphQLObject): {
151
+ export declare function evaluateVariables(variables: ValueMap, args: GraphQLObject): {
152
152
  [k: string]: GraphQLValue;
153
153
  };
154
+ export declare function variableValue(value: ValueNode, args: GraphQLObject): GraphQLValue;
154
155
  export declare const rootID = "_ROOT_";
155
156
  export declare function fragmentReference({ component, prop, }: {
156
157
  component: {
@@ -8,7 +8,6 @@ export declare class InMemorySubscriptions {
8
8
  private cache;
9
9
  constructor(cache: Cache);
10
10
  private subscribers;
11
- private referenceCounts;
12
11
  private keyVersions;
13
12
  activeFields(parent: string): string[];
14
13
  add({ parent, spec, selection, variables, parentType, }: {
@@ -70,6 +70,7 @@ export type RefetchUpdateModes = ValuesOf<typeof RefetchUpdateMode>;
70
70
  export type InputObject = {
71
71
  fields: Record<string, string>;
72
72
  types: Record<string, Record<string, string>>;
73
+ defaults: Record<string, any>;
73
74
  };
74
75
  export type BaseCompiledDocument<_Kind extends ArtifactKinds> = {
75
76
  name: string;
@@ -1,5 +1,5 @@
1
1
  import type { ConfigFile } from '../lib/config';
2
- import type { GraphQLObject, GraphQLValue, NestedList, SubscriptionSelection, SubscriptionSpec, ValueMap } from '../lib/types';
2
+ import type { GraphQLObject, GraphQLValue, NestedList, SubscriptionSelection, SubscriptionSpec, ValueMap, ValueNode } from '../lib/types';
3
3
  import { GarbageCollector } from './gc';
4
4
  import type { ListCollection } from './lists';
5
5
  import { ListManager } from './lists';
@@ -148,9 +148,10 @@ declare class CacheInternal {
148
148
  };
149
149
  collectGarbage(): void;
150
150
  }
151
- export declare function evaluateFragmentVariables(variables: ValueMap, args: GraphQLObject): {
151
+ export declare function evaluateVariables(variables: ValueMap, args: GraphQLObject): {
152
152
  [k: string]: GraphQLValue;
153
153
  };
154
+ export declare function variableValue(value: ValueNode, args: GraphQLObject): GraphQLValue;
154
155
  export declare const rootID = "_ROOT_";
155
156
  export declare function fragmentReference({ component, prop, }: {
156
157
  component: {
@@ -20,9 +20,10 @@ var cache_exports = {};
20
20
  __export(cache_exports, {
21
21
  Cache: () => Cache,
22
22
  defaultComponentField: () => defaultComponentField,
23
- evaluateFragmentVariables: () => evaluateFragmentVariables,
23
+ evaluateVariables: () => evaluateVariables,
24
24
  fragmentReference: () => fragmentReference,
25
- rootID: () => rootID
25
+ rootID: () => rootID,
26
+ variableValue: () => variableValue
26
27
  });
27
28
  module.exports = __toCommonJS(cache_exports);
28
29
  var import_lib = require("../lib");
@@ -555,10 +556,7 @@ class CacheInternal {
555
556
  key,
556
557
  {
557
558
  parent,
558
- variables: evaluateFragmentVariables(
559
- value.arguments,
560
- variables ?? {}
561
- )
559
+ variables: evaluateVariables(value.arguments, variables ?? {})
562
560
  }
563
561
  ])
564
562
  )
@@ -592,7 +590,7 @@ class CacheInternal {
592
590
  return d.name === "include";
593
591
  });
594
592
  if (includeDirective) {
595
- if (!evaluateFragmentVariables(includeDirective.arguments, variables ?? {})["if"]) {
593
+ if (!evaluateVariables(includeDirective.arguments, variables ?? {})["if"]) {
596
594
  continue;
597
595
  }
598
596
  }
@@ -600,7 +598,7 @@ class CacheInternal {
600
598
  return d.name === "skip";
601
599
  });
602
600
  if (skipDirective) {
603
- if (evaluateFragmentVariables(skipDirective.arguments, variables ?? {})["if"]) {
601
+ if (evaluateVariables(skipDirective.arguments, variables ?? {})["if"]) {
604
602
  continue;
605
603
  }
606
604
  }
@@ -899,9 +897,9 @@ class CacheInternal {
899
897
  }
900
898
  }
901
899
  }
902
- function evaluateFragmentVariables(variables, args) {
900
+ function evaluateVariables(variables, args) {
903
901
  return Object.fromEntries(
904
- Object.entries(variables).map(([key, value]) => [key, fragmentVariableValue(value, args)])
902
+ Object.entries(variables).map(([key, value]) => [key, variableValue(value, args)])
905
903
  );
906
904
  }
907
905
  function wrapInLists(target, count = 0) {
@@ -910,7 +908,7 @@ function wrapInLists(target, count = 0) {
910
908
  }
911
909
  return wrapInLists([target], count - 1);
912
910
  }
913
- function fragmentVariableValue(value, args) {
911
+ function variableValue(value, args) {
914
912
  if (value.kind === "StringValue") {
915
913
  return value.value;
916
914
  }
@@ -933,13 +931,13 @@ function fragmentVariableValue(value, args) {
933
931
  return args[value.name.value];
934
932
  }
935
933
  if (value.kind === "ListValue") {
936
- return value.values.map((value2) => fragmentVariableValue(value2, args));
934
+ return value.values.map((value2) => variableValue(value2, args));
937
935
  }
938
936
  if (value.kind === "ObjectValue") {
939
937
  return value.fields.reduce(
940
938
  (obj, field) => ({
941
939
  ...obj,
942
- [field.name.value]: fragmentVariableValue(field.value, args)
940
+ [field.name.value]: variableValue(field.value, args)
943
941
  }),
944
942
  {}
945
943
  );
@@ -961,7 +959,7 @@ function defaultComponentField({
961
959
  }) {
962
960
  return (props) => {
963
961
  const componentFn = cache._internal_unstable.componentCache[component.key];
964
- const args = evaluateFragmentVariables(component.variables ?? {}, variables ?? {});
962
+ const args = evaluateVariables(component.variables ?? {}, variables ?? {});
965
963
  return cache._internal_unstable.createComponent(componentFn, {
966
964
  ...props,
967
965
  [component.prop]: {
@@ -982,7 +980,8 @@ function defaultComponentField({
982
980
  0 && (module.exports = {
983
981
  Cache,
984
982
  defaultComponentField,
985
- evaluateFragmentVariables,
983
+ evaluateVariables,
986
984
  fragmentReference,
987
- rootID
985
+ rootID,
986
+ variableValue
988
987
  });
@@ -8,7 +8,6 @@ export declare class InMemorySubscriptions {
8
8
  private cache;
9
9
  constructor(cache: Cache);
10
10
  private subscribers;
11
- private referenceCounts;
12
11
  private keyVersions;
13
12
  activeFields(parent: string): string[];
14
13
  add({ parent, spec, selection, variables, parentType, }: {
@@ -30,11 +30,10 @@ class InMemorySubscriptions {
30
30
  constructor(cache) {
31
31
  this.cache = cache;
32
32
  }
33
- subscribers = {};
34
- referenceCounts = {};
33
+ subscribers = /* @__PURE__ */ new Map();
35
34
  keyVersions = {};
36
35
  activeFields(parent) {
37
- return Object.keys(this.subscribers[parent] || {});
36
+ return Object.keys(this.subscribers.get(parent) || {});
38
37
  }
39
38
  add({
40
39
  parent,
@@ -108,27 +107,28 @@ class InMemorySubscriptions {
108
107
  type
109
108
  }) {
110
109
  const spec = selection[0];
111
- if (!this.subscribers[id]) {
112
- this.subscribers[id] = {};
110
+ if (!this.subscribers.has(id)) {
111
+ this.subscribers.set(id, /* @__PURE__ */ new Map());
113
112
  }
114
- if (!this.subscribers[id][key]) {
115
- this.subscribers[id][key] = [];
113
+ const subscriber = this.subscribers.get(id);
114
+ if (!subscriber.has(key)) {
115
+ subscriber.set(key, {
116
+ selections: [],
117
+ referenceCounts: /* @__PURE__ */ new Map()
118
+ });
116
119
  }
120
+ const subscriberField = subscriber.get(key);
117
121
  if (!this.keyVersions[key]) {
118
122
  this.keyVersions[key] = /* @__PURE__ */ new Set();
119
123
  }
120
124
  this.keyVersions[key].add(key);
121
- if (!this.subscribers[id][key].map(([{ set }]) => set).includes(spec.set)) {
122
- this.subscribers[id][key].push([spec, selection[1]]);
123
- }
124
- if (!this.referenceCounts[id]) {
125
- this.referenceCounts[id] = {};
126
- }
127
- if (!this.referenceCounts[id][key]) {
128
- this.referenceCounts[id][key] = /* @__PURE__ */ new Map();
125
+ if (!subscriberField.selections.some(([{ set }]) => set === spec.set)) {
126
+ subscriberField.selections.push([spec, selection[1]]);
129
127
  }
130
- const counts = this.referenceCounts[id][key];
131
- counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
128
+ subscriberField.referenceCounts.set(
129
+ spec.set,
130
+ (subscriberField.referenceCounts.get(spec.set) || 0) + 1
131
+ );
132
132
  this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
133
133
  }
134
134
  registerList({
@@ -215,7 +215,7 @@ class InMemorySubscriptions {
215
215
  }
216
216
  }
217
217
  get(id, field) {
218
- return this.subscribers[id]?.[field] || [];
218
+ return this.subscribers.get(id)?.get(field)?.selections || [];
219
219
  }
220
220
  remove(id, selection, targets, variables, visited = []) {
221
221
  visited.push(id);
@@ -241,24 +241,24 @@ class InMemorySubscriptions {
241
241
  }
242
242
  }
243
243
  reset() {
244
- const subscribers = Object.entries(this.subscribers).filter(
245
- ([id]) => !id.startsWith(import_cache.rootID)
246
- );
244
+ const subscribers = [...this.subscribers.entries()].filter(([id]) => !id.startsWith(import_cache.rootID));
247
245
  for (const [id, _fields] of subscribers) {
248
- delete this.subscribers[id];
246
+ this.subscribers.delete(id);
249
247
  }
250
248
  const subscriptionSpecs = subscribers.flatMap(
251
- ([_id, fields]) => Object.values(fields).flatMap((field) => field.map(([spec]) => spec))
249
+ ([_id, fields]) => [...fields.values()].flatMap((field) => field.selections.map(([spec]) => spec))
252
250
  );
253
251
  return subscriptionSpecs;
254
252
  }
255
253
  removeSubscribers(id, fieldName, specs) {
256
254
  let targets = [];
255
+ const subscriber = this.subscribers.get(id);
256
+ const subscriberField = subscriber?.get(fieldName);
257
257
  for (const spec of specs) {
258
- if (!this.referenceCounts[id]?.[fieldName]?.has(spec.set)) {
258
+ const counts = subscriber?.get(fieldName)?.referenceCounts;
259
+ if (!counts?.has(spec.set)) {
259
260
  continue;
260
261
  }
261
- const counts = this.referenceCounts[id][fieldName];
262
262
  const newVal = (counts.get(spec.set) || 0) - 1;
263
263
  counts.set(spec.set, newVal);
264
264
  if (newVal <= 0) {
@@ -266,18 +266,19 @@ class InMemorySubscriptions {
266
266
  counts.delete(spec.set);
267
267
  }
268
268
  }
269
- if (this.subscribers[id]) {
270
- this.subscribers[id][fieldName] = this.get(id, fieldName).filter(
269
+ if (subscriberField) {
270
+ subscriberField.selections = this.get(id, fieldName).filter(
271
271
  ([{ set }]) => !targets.includes(set)
272
272
  );
273
273
  }
274
274
  }
275
275
  removeAllSubscribers(id, targets, visited = []) {
276
276
  visited.push(id);
277
- for (const field of Object.keys(this.subscribers[id] || [])) {
278
- const subscribers = targets || this.subscribers[id][field].map(([spec]) => spec);
279
- this.removeSubscribers(id, field, subscribers);
280
- const { value, kind } = this.cache._internal_unstable.storage.get(id, field);
277
+ const subscriber = this.subscribers.get(id);
278
+ for (const [key, val] of subscriber?.entries() ?? []) {
279
+ const subscribers = targets || val.selections.map(([spec]) => spec);
280
+ this.removeSubscribers(id, key, subscribers);
281
+ const { value, kind } = this.cache._internal_unstable.storage.get(id, key);
281
282
  if (kind === "scalar") {
282
283
  continue;
283
284
  }
@@ -164,7 +164,14 @@ function offsetHandlers({
164
164
  fetchUpdate: parentFetchUpdate,
165
165
  getSession
166
166
  }) {
167
- let getOffset = () => artifact.refetch?.start || (0, import_pageInfo.countPage)(artifact.refetch.path, getState()) || artifact.refetch.pageSize;
167
+ let isSinglePage = artifact.refetch?.mode === "SinglePage";
168
+ let getOffset = () => {
169
+ let offset = artifact.refetch?.start || (0, import_pageInfo.countPage)(artifact.refetch.path, getState()) || artifact.refetch.pageSize;
170
+ if (isSinglePage) {
171
+ offset += getVariables()?.offset ?? 0;
172
+ }
173
+ return offset;
174
+ };
168
175
  let currentOffset = getOffset() ?? 0;
169
176
  return {
170
177
  loadNextPage: async ({
@@ -183,7 +190,6 @@ function offsetHandlers({
183
190
  if (!queryVariables.limit && !artifact.refetch.pageSize) {
184
191
  throw (0, import_pageInfo.missingPageSizeError)("loadNextPage");
185
192
  }
186
- let isSinglePage = artifact.refetch?.mode === "SinglePage";
187
193
  const targetFetch = isSinglePage ? parentFetch : parentFetchUpdate;
188
194
  await targetFetch({
189
195
  variables: queryVariables,
@@ -70,6 +70,7 @@ export type RefetchUpdateModes = ValuesOf<typeof RefetchUpdateMode>;
70
70
  export type InputObject = {
71
71
  fields: Record<string, string>;
72
72
  types: Record<string, Record<string, string>>;
73
+ defaults: Record<string, any>;
73
74
  };
74
75
  export type BaseCompiledDocument<_Kind extends ArtifactKinds> = {
75
76
  name: string;
@@ -1,5 +1,5 @@
1
1
  import type { ConfigFile } from '../lib/config';
2
- import type { GraphQLObject, GraphQLValue, NestedList, SubscriptionSelection, SubscriptionSpec, ValueMap } from '../lib/types';
2
+ import type { GraphQLObject, GraphQLValue, NestedList, SubscriptionSelection, SubscriptionSpec, ValueMap, ValueNode } from '../lib/types';
3
3
  import { GarbageCollector } from './gc';
4
4
  import type { ListCollection } from './lists';
5
5
  import { ListManager } from './lists';
@@ -148,9 +148,10 @@ declare class CacheInternal {
148
148
  };
149
149
  collectGarbage(): void;
150
150
  }
151
- export declare function evaluateFragmentVariables(variables: ValueMap, args: GraphQLObject): {
151
+ export declare function evaluateVariables(variables: ValueMap, args: GraphQLObject): {
152
152
  [k: string]: GraphQLValue;
153
153
  };
154
+ export declare function variableValue(value: ValueNode, args: GraphQLObject): GraphQLValue;
154
155
  export declare const rootID = "_ROOT_";
155
156
  export declare function fragmentReference({ component, prop, }: {
156
157
  component: {
@@ -528,10 +528,7 @@ class CacheInternal {
528
528
  key,
529
529
  {
530
530
  parent,
531
- variables: evaluateFragmentVariables(
532
- value.arguments,
533
- variables ?? {}
534
- )
531
+ variables: evaluateVariables(value.arguments, variables ?? {})
535
532
  }
536
533
  ])
537
534
  )
@@ -565,7 +562,7 @@ class CacheInternal {
565
562
  return d.name === "include";
566
563
  });
567
564
  if (includeDirective) {
568
- if (!evaluateFragmentVariables(includeDirective.arguments, variables ?? {})["if"]) {
565
+ if (!evaluateVariables(includeDirective.arguments, variables ?? {})["if"]) {
569
566
  continue;
570
567
  }
571
568
  }
@@ -573,7 +570,7 @@ class CacheInternal {
573
570
  return d.name === "skip";
574
571
  });
575
572
  if (skipDirective) {
576
- if (evaluateFragmentVariables(skipDirective.arguments, variables ?? {})["if"]) {
573
+ if (evaluateVariables(skipDirective.arguments, variables ?? {})["if"]) {
577
574
  continue;
578
575
  }
579
576
  }
@@ -872,9 +869,9 @@ class CacheInternal {
872
869
  }
873
870
  }
874
871
  }
875
- function evaluateFragmentVariables(variables, args) {
872
+ function evaluateVariables(variables, args) {
876
873
  return Object.fromEntries(
877
- Object.entries(variables).map(([key, value]) => [key, fragmentVariableValue(value, args)])
874
+ Object.entries(variables).map(([key, value]) => [key, variableValue(value, args)])
878
875
  );
879
876
  }
880
877
  function wrapInLists(target, count = 0) {
@@ -883,7 +880,7 @@ function wrapInLists(target, count = 0) {
883
880
  }
884
881
  return wrapInLists([target], count - 1);
885
882
  }
886
- function fragmentVariableValue(value, args) {
883
+ function variableValue(value, args) {
887
884
  if (value.kind === "StringValue") {
888
885
  return value.value;
889
886
  }
@@ -906,13 +903,13 @@ function fragmentVariableValue(value, args) {
906
903
  return args[value.name.value];
907
904
  }
908
905
  if (value.kind === "ListValue") {
909
- return value.values.map((value2) => fragmentVariableValue(value2, args));
906
+ return value.values.map((value2) => variableValue(value2, args));
910
907
  }
911
908
  if (value.kind === "ObjectValue") {
912
909
  return value.fields.reduce(
913
910
  (obj, field) => ({
914
911
  ...obj,
915
- [field.name.value]: fragmentVariableValue(field.value, args)
912
+ [field.name.value]: variableValue(field.value, args)
916
913
  }),
917
914
  {}
918
915
  );
@@ -934,7 +931,7 @@ function defaultComponentField({
934
931
  }) {
935
932
  return (props) => {
936
933
  const componentFn = cache._internal_unstable.componentCache[component.key];
937
- const args = evaluateFragmentVariables(component.variables ?? {}, variables ?? {});
934
+ const args = evaluateVariables(component.variables ?? {}, variables ?? {});
938
935
  return cache._internal_unstable.createComponent(componentFn, {
939
936
  ...props,
940
937
  [component.prop]: {
@@ -954,7 +951,8 @@ function defaultComponentField({
954
951
  export {
955
952
  Cache,
956
953
  defaultComponentField,
957
- evaluateFragmentVariables,
954
+ evaluateVariables,
958
955
  fragmentReference,
959
- rootID
956
+ rootID,
957
+ variableValue
960
958
  };
@@ -8,7 +8,6 @@ export declare class InMemorySubscriptions {
8
8
  private cache;
9
9
  constructor(cache: Cache);
10
10
  private subscribers;
11
- private referenceCounts;
12
11
  private keyVersions;
13
12
  activeFields(parent: string): string[];
14
13
  add({ parent, spec, selection, variables, parentType, }: {
@@ -7,11 +7,10 @@ class InMemorySubscriptions {
7
7
  constructor(cache) {
8
8
  this.cache = cache;
9
9
  }
10
- subscribers = {};
11
- referenceCounts = {};
10
+ subscribers = /* @__PURE__ */ new Map();
12
11
  keyVersions = {};
13
12
  activeFields(parent) {
14
- return Object.keys(this.subscribers[parent] || {});
13
+ return Object.keys(this.subscribers.get(parent) || {});
15
14
  }
16
15
  add({
17
16
  parent,
@@ -85,27 +84,28 @@ class InMemorySubscriptions {
85
84
  type
86
85
  }) {
87
86
  const spec = selection[0];
88
- if (!this.subscribers[id]) {
89
- this.subscribers[id] = {};
87
+ if (!this.subscribers.has(id)) {
88
+ this.subscribers.set(id, /* @__PURE__ */ new Map());
90
89
  }
91
- if (!this.subscribers[id][key]) {
92
- this.subscribers[id][key] = [];
90
+ const subscriber = this.subscribers.get(id);
91
+ if (!subscriber.has(key)) {
92
+ subscriber.set(key, {
93
+ selections: [],
94
+ referenceCounts: /* @__PURE__ */ new Map()
95
+ });
93
96
  }
97
+ const subscriberField = subscriber.get(key);
94
98
  if (!this.keyVersions[key]) {
95
99
  this.keyVersions[key] = /* @__PURE__ */ new Set();
96
100
  }
97
101
  this.keyVersions[key].add(key);
98
- if (!this.subscribers[id][key].map(([{ set }]) => set).includes(spec.set)) {
99
- this.subscribers[id][key].push([spec, selection[1]]);
100
- }
101
- if (!this.referenceCounts[id]) {
102
- this.referenceCounts[id] = {};
103
- }
104
- if (!this.referenceCounts[id][key]) {
105
- this.referenceCounts[id][key] = /* @__PURE__ */ new Map();
102
+ if (!subscriberField.selections.some(([{ set }]) => set === spec.set)) {
103
+ subscriberField.selections.push([spec, selection[1]]);
106
104
  }
107
- const counts = this.referenceCounts[id][key];
108
- counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
105
+ subscriberField.referenceCounts.set(
106
+ spec.set,
107
+ (subscriberField.referenceCounts.get(spec.set) || 0) + 1
108
+ );
109
109
  this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
110
110
  }
111
111
  registerList({
@@ -192,7 +192,7 @@ class InMemorySubscriptions {
192
192
  }
193
193
  }
194
194
  get(id, field) {
195
- return this.subscribers[id]?.[field] || [];
195
+ return this.subscribers.get(id)?.get(field)?.selections || [];
196
196
  }
197
197
  remove(id, selection, targets, variables, visited = []) {
198
198
  visited.push(id);
@@ -218,24 +218,24 @@ class InMemorySubscriptions {
218
218
  }
219
219
  }
220
220
  reset() {
221
- const subscribers = Object.entries(this.subscribers).filter(
222
- ([id]) => !id.startsWith(rootID)
223
- );
221
+ const subscribers = [...this.subscribers.entries()].filter(([id]) => !id.startsWith(rootID));
224
222
  for (const [id, _fields] of subscribers) {
225
- delete this.subscribers[id];
223
+ this.subscribers.delete(id);
226
224
  }
227
225
  const subscriptionSpecs = subscribers.flatMap(
228
- ([_id, fields]) => Object.values(fields).flatMap((field) => field.map(([spec]) => spec))
226
+ ([_id, fields]) => [...fields.values()].flatMap((field) => field.selections.map(([spec]) => spec))
229
227
  );
230
228
  return subscriptionSpecs;
231
229
  }
232
230
  removeSubscribers(id, fieldName, specs) {
233
231
  let targets = [];
232
+ const subscriber = this.subscribers.get(id);
233
+ const subscriberField = subscriber?.get(fieldName);
234
234
  for (const spec of specs) {
235
- if (!this.referenceCounts[id]?.[fieldName]?.has(spec.set)) {
235
+ const counts = subscriber?.get(fieldName)?.referenceCounts;
236
+ if (!counts?.has(spec.set)) {
236
237
  continue;
237
238
  }
238
- const counts = this.referenceCounts[id][fieldName];
239
239
  const newVal = (counts.get(spec.set) || 0) - 1;
240
240
  counts.set(spec.set, newVal);
241
241
  if (newVal <= 0) {
@@ -243,18 +243,19 @@ class InMemorySubscriptions {
243
243
  counts.delete(spec.set);
244
244
  }
245
245
  }
246
- if (this.subscribers[id]) {
247
- this.subscribers[id][fieldName] = this.get(id, fieldName).filter(
246
+ if (subscriberField) {
247
+ subscriberField.selections = this.get(id, fieldName).filter(
248
248
  ([{ set }]) => !targets.includes(set)
249
249
  );
250
250
  }
251
251
  }
252
252
  removeAllSubscribers(id, targets, visited = []) {
253
253
  visited.push(id);
254
- for (const field of Object.keys(this.subscribers[id] || [])) {
255
- const subscribers = targets || this.subscribers[id][field].map(([spec]) => spec);
256
- this.removeSubscribers(id, field, subscribers);
257
- const { value, kind } = this.cache._internal_unstable.storage.get(id, field);
254
+ const subscriber = this.subscribers.get(id);
255
+ for (const [key, val] of subscriber?.entries() ?? []) {
256
+ const subscribers = targets || val.selections.map(([spec]) => spec);
257
+ this.removeSubscribers(id, key, subscribers);
258
+ const { value, kind } = this.cache._internal_unstable.storage.get(id, key);
258
259
  if (kind === "scalar") {
259
260
  continue;
260
261
  }
@@ -140,7 +140,14 @@ function offsetHandlers({
140
140
  fetchUpdate: parentFetchUpdate,
141
141
  getSession
142
142
  }) {
143
- let getOffset = () => artifact.refetch?.start || countPage(artifact.refetch.path, getState()) || artifact.refetch.pageSize;
143
+ let isSinglePage = artifact.refetch?.mode === "SinglePage";
144
+ let getOffset = () => {
145
+ let offset = artifact.refetch?.start || countPage(artifact.refetch.path, getState()) || artifact.refetch.pageSize;
146
+ if (isSinglePage) {
147
+ offset += getVariables()?.offset ?? 0;
148
+ }
149
+ return offset;
150
+ };
144
151
  let currentOffset = getOffset() ?? 0;
145
152
  return {
146
153
  loadNextPage: async ({
@@ -159,7 +166,6 @@ function offsetHandlers({
159
166
  if (!queryVariables.limit && !artifact.refetch.pageSize) {
160
167
  throw missingPageSizeError("loadNextPage");
161
168
  }
162
- let isSinglePage = artifact.refetch?.mode === "SinglePage";
163
169
  const targetFetch = isSinglePage ? parentFetch : parentFetchUpdate;
164
170
  await targetFetch({
165
171
  variables: queryVariables,
@@ -70,6 +70,7 @@ export type RefetchUpdateModes = ValuesOf<typeof RefetchUpdateMode>;
70
70
  export type InputObject = {
71
71
  fields: Record<string, string>;
72
72
  types: Record<string, Record<string, string>>;
73
+ defaults: Record<string, any>;
73
74
  };
74
75
  export type BaseCompiledDocument<_Kind extends ArtifactKinds> = {
75
76
  name: string;