houdini 1.1.4-react.0 → 1.1.4

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 (47) hide show
  1. package/build/cmd-cjs/index.js +607 -444
  2. package/build/cmd-esm/index.js +607 -444
  3. package/build/codegen/transforms/fragmentVariables.d.ts +0 -11
  4. package/build/codegen-cjs/index.js +577 -403
  5. package/build/codegen-esm/index.js +577 -403
  6. package/build/lib/config.d.ts +1 -1
  7. package/build/lib/parse.d.ts +1 -2
  8. package/build/lib/types.d.ts +1 -4
  9. package/build/lib-cjs/index.js +187 -195
  10. package/build/lib-esm/index.js +187 -195
  11. package/build/runtime/cache/cache.d.ts +4 -2
  12. package/build/runtime/client/documentStore.d.ts +0 -3
  13. package/build/runtime/client/index.d.ts +1 -1
  14. package/build/runtime/lib/types.d.ts +4 -46
  15. package/build/runtime-cjs/cache/cache.d.ts +4 -2
  16. package/build/runtime-cjs/cache/cache.js +37 -14
  17. package/build/runtime-cjs/client/documentStore.d.ts +0 -3
  18. package/build/runtime-cjs/client/documentStore.js +6 -11
  19. package/build/runtime-cjs/client/index.d.ts +1 -1
  20. package/build/runtime-cjs/client/plugins/cache.js +3 -5
  21. package/build/runtime-cjs/client/plugins/fragment.js +1 -8
  22. package/build/runtime-cjs/client/plugins/query.js +1 -2
  23. package/build/runtime-cjs/lib/types.d.ts +4 -46
  24. package/build/runtime-esm/cache/cache.d.ts +4 -2
  25. package/build/runtime-esm/cache/cache.js +37 -14
  26. package/build/runtime-esm/client/documentStore.d.ts +0 -3
  27. package/build/runtime-esm/client/documentStore.js +6 -11
  28. package/build/runtime-esm/client/index.d.ts +1 -1
  29. package/build/runtime-esm/client/plugins/cache.js +3 -5
  30. package/build/runtime-esm/client/plugins/fragment.js +1 -8
  31. package/build/runtime-esm/client/plugins/query.js +1 -2
  32. package/build/runtime-esm/lib/types.d.ts +4 -46
  33. package/build/test-cjs/index.js +598 -428
  34. package/build/test-esm/index.js +598 -428
  35. package/build/vite-cjs/index.js +617 -454
  36. package/build/vite-esm/index.js +617 -454
  37. package/package.json +3 -1
  38. package/build/runtime/lib/pageInfo.d.ts +0 -7
  39. package/build/runtime/lib/pagination.d.ts +0 -29
  40. package/build/runtime-cjs/lib/pageInfo.d.ts +0 -7
  41. package/build/runtime-cjs/lib/pageInfo.js +0 -79
  42. package/build/runtime-cjs/lib/pagination.d.ts +0 -29
  43. package/build/runtime-cjs/lib/pagination.js +0 -231
  44. package/build/runtime-esm/lib/pageInfo.d.ts +0 -7
  45. package/build/runtime-esm/lib/pageInfo.js +0 -52
  46. package/build/runtime-esm/lib/pagination.d.ts +0 -29
  47. package/build/runtime-esm/lib/pagination.js +0 -206
@@ -25,7 +25,6 @@ declare global {
25
25
  };
26
26
  optimisticResponse?: GraphQLObject;
27
27
  parentID?: string;
28
- silenceLoading?: boolean;
29
28
  }
30
29
  }
31
30
  }
@@ -142,6 +141,10 @@ export type SubscriptionSelection = {
142
141
  connection: boolean;
143
142
  type: string;
144
143
  };
144
+ directives?: {
145
+ name: string;
146
+ arguments: ValueMap;
147
+ }[];
145
148
  updates?: string[];
146
149
  visible?: boolean;
147
150
  filters?: Record<string, {
@@ -194,51 +197,6 @@ export type ValueOf<Parent> = Parent[keyof Parent];
194
197
  export declare const fragmentKey = " $fragments";
195
198
  export type ValueNode = VariableNode | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ListValueNode | ObjectValueNode;
196
199
  export type ValueMap = Record<string, ValueNode>;
197
- export type FetchParams<_Input> = {
198
- variables?: _Input;
199
- /**
200
- * The policy to use when performing the fetch. If set to CachePolicy.NetworkOnly,
201
- * a request will always be sent, even if the variables are the same as the last call
202
- * to fetch.
203
- */
204
- policy?: CachePolicies;
205
- /**
206
- * An object that will be passed to the fetch function.
207
- * You can do what you want with it!
208
- */
209
- metadata?: App.Metadata;
210
- };
211
- export type FetchFn<_Data extends GraphQLObject, _Input = any> = (params?: FetchParams<_Input>) => Promise<QueryResult<_Data, _Input>>;
212
- export type CursorHandlers<_Data extends GraphQLObject, _Input> = {
213
- loadNextPage: (args?: {
214
- first?: number;
215
- after?: string;
216
- fetch?: typeof globalThis.fetch;
217
- metadata?: {};
218
- }) => Promise<void>;
219
- loadPreviousPage: (args?: {
220
- last?: number;
221
- before?: string;
222
- fetch?: typeof globalThis.fetch;
223
- metadata?: {};
224
- }) => Promise<void>;
225
- fetch(args?: FetchParams<_Input> | undefined): Promise<QueryResult<_Data, _Input>>;
226
- };
227
- export type OffsetHandlers<_Data extends GraphQLObject, _Input> = {
228
- loadNextPage: (args?: {
229
- limit?: number;
230
- offset?: number;
231
- metadata?: {};
232
- fetch?: typeof globalThis.fetch;
233
- }) => Promise<void>;
234
- fetch(args?: FetchParams<_Input> | undefined): Promise<QueryResult<_Data, _Input>>;
235
- };
236
- export type PageInfo = {
237
- startCursor: string | null;
238
- endCursor: string | null;
239
- hasNextPage: boolean;
240
- hasPreviousPage: boolean;
241
- };
242
200
  interface IntValueNode {
243
201
  readonly kind: 'IntValue';
244
202
  readonly value: string;
@@ -87,12 +87,13 @@ declare class CacheInternal {
87
87
  forceNotify?: boolean;
88
88
  forceStale?: boolean;
89
89
  }): FieldSelection[];
90
- getSelection({ selection, parent, variables, stepsFromConnection, ignoreMasking, }: {
90
+ getSelection({ selection, parent, variables, stepsFromConnection, ignoreMasking, fullCheck, }: {
91
91
  selection: SubscriptionSelection;
92
92
  parent?: string;
93
93
  variables?: {};
94
94
  stepsFromConnection?: number | null;
95
95
  ignoreMasking?: boolean;
96
+ fullCheck?: boolean;
96
97
  }): {
97
98
  data: GraphQLObject | null;
98
99
  partial: boolean;
@@ -103,12 +104,13 @@ declare class CacheInternal {
103
104
  id(type: string, id: string): string | null;
104
105
  idFields(type: string): string[];
105
106
  computeID(type: string, data: any): string;
106
- hydrateNestedList({ fields, variables, linkedList, stepsFromConnection, ignoreMasking, }: {
107
+ hydrateNestedList({ fields, variables, linkedList, stepsFromConnection, ignoreMasking, fullCheck, }: {
107
108
  fields: SubscriptionSelection;
108
109
  variables?: {};
109
110
  linkedList: NestedList;
110
111
  stepsFromConnection: number | null;
111
112
  ignoreMasking: boolean;
113
+ fullCheck?: boolean;
112
114
  }): {
113
115
  data: NestedList<GraphQLValue>;
114
116
  partial: boolean;
@@ -471,7 +471,8 @@ class CacheInternal {
471
471
  parent = rootID,
472
472
  variables,
473
473
  stepsFromConnection = null,
474
- ignoreMasking
474
+ ignoreMasking,
475
+ fullCheck = false
475
476
  }) {
476
477
  if (parent === null) {
477
478
  return { data: null, partial: false, stale: false, hasData: true };
@@ -496,11 +497,28 @@ class CacheInternal {
496
497
  let targetSelection = (0, import_selection.getFieldsForType)(selection, typename);
497
498
  for (const [
498
499
  attributeName,
499
- { type, keyRaw, selection: fieldSelection, nullable, list, visible }
500
+ { type, keyRaw, selection: fieldSelection, nullable, list, visible, directives }
500
501
  ] of Object.entries(targetSelection)) {
501
- if (!visible && !ignoreMasking) {
502
+ if (!visible && !ignoreMasking && !fullCheck) {
502
503
  continue;
503
504
  }
505
+ const includeDirective = directives?.find((d) => {
506
+ return d.name === "include";
507
+ });
508
+ if (includeDirective) {
509
+ if (!evaluateFragmentVariables(includeDirective.arguments, variables ?? {})["if"]) {
510
+ continue;
511
+ }
512
+ }
513
+ const skipDirective = directives?.find((d) => {
514
+ return d.name === "skip";
515
+ });
516
+ if (skipDirective) {
517
+ if (evaluateFragmentVariables(skipDirective.arguments, variables ?? {})["if"]) {
518
+ continue;
519
+ }
520
+ }
521
+ const fieldTarget = visible || ignoreMasking ? target : {};
504
522
  const key = (0, import_stuff.evaluateKey)(keyRaw, variables);
505
523
  const { value } = this.storage.get(parent, key);
506
524
  const dt_field = this.staleManager.getFieldTime(parent, key);
@@ -523,16 +541,16 @@ class CacheInternal {
523
541
  partial = true;
524
542
  }
525
543
  if (typeof value === "undefined" || value === null) {
526
- target[attributeName] = null;
544
+ fieldTarget[attributeName] = null;
527
545
  if (typeof value !== "undefined") {
528
546
  hasData = true;
529
547
  }
530
548
  } else if (!fieldSelection) {
531
549
  const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
532
550
  if (fnUnmarshal) {
533
- target[attributeName] = fnUnmarshal(value);
551
+ fieldTarget[attributeName] = fnUnmarshal(value);
534
552
  } else {
535
- target[attributeName] = value;
553
+ fieldTarget[attributeName] = value;
536
554
  }
537
555
  hasData = true;
538
556
  } else if (Array.isArray(value)) {
@@ -541,9 +559,10 @@ class CacheInternal {
541
559
  variables,
542
560
  linkedList: value,
543
561
  stepsFromConnection: nextStep,
544
- ignoreMasking: !!ignoreMasking
562
+ ignoreMasking: !!ignoreMasking,
563
+ fullCheck
545
564
  });
546
- target[attributeName] = listValue.data;
565
+ fieldTarget[attributeName] = listValue.data;
547
566
  if (listValue.partial) {
548
567
  partial = true;
549
568
  }
@@ -559,9 +578,10 @@ class CacheInternal {
559
578
  selection: fieldSelection,
560
579
  variables,
561
580
  stepsFromConnection: nextStep,
562
- ignoreMasking
581
+ ignoreMasking,
582
+ fullCheck
563
583
  });
564
- target[attributeName] = objectFields.data;
584
+ fieldTarget[attributeName] = objectFields.data;
565
585
  if (objectFields.partial) {
566
586
  partial = true;
567
587
  }
@@ -572,7 +592,7 @@ class CacheInternal {
572
592
  hasData = true;
573
593
  }
574
594
  }
575
- if (target[attributeName] === null && !nullable && !embeddedCursor) {
595
+ if (fieldTarget[attributeName] === null && !nullable && !embeddedCursor) {
576
596
  cascadeNull = true;
577
597
  }
578
598
  }
@@ -604,7 +624,8 @@ class CacheInternal {
604
624
  variables,
605
625
  linkedList,
606
626
  stepsFromConnection,
607
- ignoreMasking
627
+ ignoreMasking,
628
+ fullCheck
608
629
  }) {
609
630
  const result = [];
610
631
  let partialData = false;
@@ -617,7 +638,8 @@ class CacheInternal {
617
638
  variables,
618
639
  linkedList: entry,
619
640
  stepsFromConnection,
620
- ignoreMasking
641
+ ignoreMasking,
642
+ fullCheck
621
643
  });
622
644
  result.push(nestedValue.data);
623
645
  if (nestedValue.partial) {
@@ -639,7 +661,8 @@ class CacheInternal {
639
661
  selection: fields,
640
662
  variables,
641
663
  stepsFromConnection,
642
- ignoreMasking
664
+ ignoreMasking,
665
+ fullCheck
643
666
  });
644
667
  result.push(data);
645
668
  if (partial) {
@@ -5,9 +5,6 @@ import { Writable } from '../lib/store';
5
5
  import type { DocumentArtifact, QueryResult, GraphQLObject, SubscriptionSpec, CachePolicies } from '../lib/types';
6
6
  export declare class DocumentStore<_Data extends GraphQLObject, _Input extends Record<string, any>> extends Writable<QueryResult<_Data, _Input>> {
7
7
  #private;
8
- pendingPromise: {
9
- then: (val: any) => void;
10
- } | null;
11
8
  constructor({ artifact, plugins, pipeline, client, cache, initialValue, fetching, }: {
12
9
  artifact: DocumentArtifact;
13
10
  plugins?: ClientHooks[];
@@ -38,7 +38,6 @@ class DocumentStore extends import_store.Writable {
38
38
  #plugins;
39
39
  #lastVariables;
40
40
  #lastContext = null;
41
- pendingPromise = null;
42
41
  constructor({
43
42
  artifact,
44
43
  plugins,
@@ -111,7 +110,7 @@ class DocumentStore extends import_store.Writable {
111
110
  const draft = context.draft();
112
111
  draft.variables = variables ?? null;
113
112
  context = context.apply(draft, false);
114
- const promise = new Promise((resolve, reject) => {
113
+ return await new Promise((resolve, reject) => {
115
114
  const state = {
116
115
  setup,
117
116
  currentStep: 0,
@@ -120,17 +119,12 @@ class DocumentStore extends import_store.Writable {
120
119
  promise: {
121
120
  resolved: false,
122
121
  resolve,
123
- reject,
124
- then: (...args) => promise.then(...args)
122
+ reject
125
123
  },
126
124
  context
127
125
  };
128
- if (this.pendingPromise === null) {
129
- this.pendingPromise = state.promise;
130
- }
131
126
  this.#step("forward", state);
132
127
  });
133
- return await promise;
134
128
  }
135
129
  async cleanup() {
136
130
  for (const plugin of this.#plugins) {
@@ -249,15 +243,16 @@ class DocumentStore extends import_store.Writable {
249
243
  value
250
244
  );
251
245
  }
252
- if (!ctx.silenceEcho || value.data !== this.state.data) {
253
- this.set(value);
254
- }
255
246
  if (!ctx.promise.resolved) {
256
247
  ctx.promise.resolve(value);
257
248
  ctx.promise.resolved = true;
258
249
  }
259
250
  this.#lastContext = ctx.context.draft();
260
251
  this.#lastVariables = this.#lastContext.stuff.inputs.marshaled;
252
+ if (ctx.silenceEcho && value.data === this.state.data) {
253
+ return;
254
+ }
255
+ this.set(value);
261
256
  }
262
257
  }
263
258
  class ClientPluginContextWrapper {
@@ -3,7 +3,7 @@ import type { DocumentArtifact, GraphQLObject, NestedList } from '../lib/types';
3
3
  import type { ClientPlugin, ClientHooks } from './documentStore';
4
4
  import { DocumentStore } from './documentStore';
5
5
  import { type FetchParamFn, type ThrowOnErrorParams } from './plugins';
6
- export { DocumentStore, type ClientPlugin, type SendParams } from './documentStore';
6
+ export { DocumentStore, type ClientPlugin } from './documentStore';
7
7
  export { fetch, mutation, query, subscription } from './plugins';
8
8
  type ConstructorArgs = {
9
9
  url: string;
@@ -41,12 +41,12 @@ const cachePolicy = ({
41
41
  network(ctx, { initialValue, next, resolve, marshalVariables }) {
42
42
  const { policy, artifact } = ctx;
43
43
  let useCache = false;
44
- if (enabled && (artifact.kind === import_types.ArtifactKind.Query || artifact.kind === import_types.ArtifactKind.Fragment) && !ctx.cacheParams?.disableRead) {
44
+ if (enabled && artifact.kind === import_types.ArtifactKind.Query && !ctx.cacheParams?.disableRead) {
45
45
  if (policy !== import_types.CachePolicy.NetworkOnly) {
46
46
  const value = localCache.read({
47
47
  selection: artifact.selection,
48
48
  variables: marshalVariables(ctx),
49
- parent: ctx.stuff?.parentID
49
+ fullCheck: true
50
50
  });
51
51
  const allowed = !value.partial || artifact.kind === import_types.ArtifactKind.Query && artifact.partial;
52
52
  if (policy === import_types.CachePolicy.CacheOnly) {
@@ -82,9 +82,7 @@ const cachePolicy = ({
82
82
  localCache._internal_unstable.collectGarbage();
83
83
  }, 0);
84
84
  }
85
- if (!ctx.stuff?.silenceLoading) {
86
- setFetching(!useCache);
87
- }
85
+ setFetching(!useCache);
88
86
  return next(ctx);
89
87
  },
90
88
  afterNetwork(ctx, { resolve, value, marshalVariables }) {
@@ -28,22 +28,16 @@ __export(fragment_exports, {
28
28
  });
29
29
  module.exports = __toCommonJS(fragment_exports);
30
30
  var import_cache = __toESM(require("../../cache"), 1);
31
- var import_deepEquals = require("../../lib/deepEquals");
32
31
  var import_types = require("../../lib/types");
33
32
  var import_utils = require("../utils");
34
33
  const fragment = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Fragment, function() {
35
34
  let subscriptionSpec = null;
36
- let lastReference = null;
37
35
  return {
38
36
  start(ctx, { next, resolve, variablesChanged, marshalVariables }) {
39
37
  if (!ctx.stuff.parentID) {
40
38
  return next(ctx);
41
39
  }
42
- const currentReference = {
43
- parent: ctx.stuff.parentID,
44
- variables: marshalVariables(ctx)
45
- };
46
- if (!ctx.cacheParams?.disableSubscriptions && (!(0, import_deepEquals.deepEquals)(lastReference, currentReference) || variablesChanged(ctx))) {
40
+ if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
47
41
  if (subscriptionSpec) {
48
42
  import_cache.default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
49
43
  }
@@ -66,7 +60,6 @@ const fragment = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Frag
66
60
  }
67
61
  };
68
62
  import_cache.default.subscribe(subscriptionSpec, variables);
69
- lastReference = currentReference;
70
63
  }
71
64
  next(ctx);
72
65
  },
@@ -47,11 +47,10 @@ const query = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Query,
47
47
  import_cache.default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
48
48
  }
49
49
  lastVariables = { ...marshalVariables(ctx) };
50
- const variables = lastVariables;
51
50
  subscriptionSpec = {
52
51
  rootType: ctx.artifact.rootType,
53
52
  selection: ctx.artifact.selection,
54
- variables: () => variables,
53
+ variables: () => lastVariables,
55
54
  set: (newValue) => {
56
55
  resolve(ctx, {
57
56
  data: newValue,
@@ -25,7 +25,6 @@ declare global {
25
25
  };
26
26
  optimisticResponse?: GraphQLObject;
27
27
  parentID?: string;
28
- silenceLoading?: boolean;
29
28
  }
30
29
  }
31
30
  }
@@ -142,6 +141,10 @@ export type SubscriptionSelection = {
142
141
  connection: boolean;
143
142
  type: string;
144
143
  };
144
+ directives?: {
145
+ name: string;
146
+ arguments: ValueMap;
147
+ }[];
145
148
  updates?: string[];
146
149
  visible?: boolean;
147
150
  filters?: Record<string, {
@@ -194,51 +197,6 @@ export type ValueOf<Parent> = Parent[keyof Parent];
194
197
  export declare const fragmentKey = " $fragments";
195
198
  export type ValueNode = VariableNode | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ListValueNode | ObjectValueNode;
196
199
  export type ValueMap = Record<string, ValueNode>;
197
- export type FetchParams<_Input> = {
198
- variables?: _Input;
199
- /**
200
- * The policy to use when performing the fetch. If set to CachePolicy.NetworkOnly,
201
- * a request will always be sent, even if the variables are the same as the last call
202
- * to fetch.
203
- */
204
- policy?: CachePolicies;
205
- /**
206
- * An object that will be passed to the fetch function.
207
- * You can do what you want with it!
208
- */
209
- metadata?: App.Metadata;
210
- };
211
- export type FetchFn<_Data extends GraphQLObject, _Input = any> = (params?: FetchParams<_Input>) => Promise<QueryResult<_Data, _Input>>;
212
- export type CursorHandlers<_Data extends GraphQLObject, _Input> = {
213
- loadNextPage: (args?: {
214
- first?: number;
215
- after?: string;
216
- fetch?: typeof globalThis.fetch;
217
- metadata?: {};
218
- }) => Promise<void>;
219
- loadPreviousPage: (args?: {
220
- last?: number;
221
- before?: string;
222
- fetch?: typeof globalThis.fetch;
223
- metadata?: {};
224
- }) => Promise<void>;
225
- fetch(args?: FetchParams<_Input> | undefined): Promise<QueryResult<_Data, _Input>>;
226
- };
227
- export type OffsetHandlers<_Data extends GraphQLObject, _Input> = {
228
- loadNextPage: (args?: {
229
- limit?: number;
230
- offset?: number;
231
- metadata?: {};
232
- fetch?: typeof globalThis.fetch;
233
- }) => Promise<void>;
234
- fetch(args?: FetchParams<_Input> | undefined): Promise<QueryResult<_Data, _Input>>;
235
- };
236
- export type PageInfo = {
237
- startCursor: string | null;
238
- endCursor: string | null;
239
- hasNextPage: boolean;
240
- hasPreviousPage: boolean;
241
- };
242
200
  interface IntValueNode {
243
201
  readonly kind: 'IntValue';
244
202
  readonly value: string;
@@ -87,12 +87,13 @@ declare class CacheInternal {
87
87
  forceNotify?: boolean;
88
88
  forceStale?: boolean;
89
89
  }): FieldSelection[];
90
- getSelection({ selection, parent, variables, stepsFromConnection, ignoreMasking, }: {
90
+ getSelection({ selection, parent, variables, stepsFromConnection, ignoreMasking, fullCheck, }: {
91
91
  selection: SubscriptionSelection;
92
92
  parent?: string;
93
93
  variables?: {};
94
94
  stepsFromConnection?: number | null;
95
95
  ignoreMasking?: boolean;
96
+ fullCheck?: boolean;
96
97
  }): {
97
98
  data: GraphQLObject | null;
98
99
  partial: boolean;
@@ -103,12 +104,13 @@ declare class CacheInternal {
103
104
  id(type: string, id: string): string | null;
104
105
  idFields(type: string): string[];
105
106
  computeID(type: string, data: any): string;
106
- hydrateNestedList({ fields, variables, linkedList, stepsFromConnection, ignoreMasking, }: {
107
+ hydrateNestedList({ fields, variables, linkedList, stepsFromConnection, ignoreMasking, fullCheck, }: {
107
108
  fields: SubscriptionSelection;
108
109
  variables?: {};
109
110
  linkedList: NestedList;
110
111
  stepsFromConnection: number | null;
111
112
  ignoreMasking: boolean;
113
+ fullCheck?: boolean;
112
114
  }): {
113
115
  data: NestedList<GraphQLValue>;
114
116
  partial: boolean;
@@ -446,7 +446,8 @@ class CacheInternal {
446
446
  parent = rootID,
447
447
  variables,
448
448
  stepsFromConnection = null,
449
- ignoreMasking
449
+ ignoreMasking,
450
+ fullCheck = false
450
451
  }) {
451
452
  if (parent === null) {
452
453
  return { data: null, partial: false, stale: false, hasData: true };
@@ -471,11 +472,28 @@ class CacheInternal {
471
472
  let targetSelection = getFieldsForType(selection, typename);
472
473
  for (const [
473
474
  attributeName,
474
- { type, keyRaw, selection: fieldSelection, nullable, list, visible }
475
+ { type, keyRaw, selection: fieldSelection, nullable, list, visible, directives }
475
476
  ] of Object.entries(targetSelection)) {
476
- if (!visible && !ignoreMasking) {
477
+ if (!visible && !ignoreMasking && !fullCheck) {
477
478
  continue;
478
479
  }
480
+ const includeDirective = directives?.find((d) => {
481
+ return d.name === "include";
482
+ });
483
+ if (includeDirective) {
484
+ if (!evaluateFragmentVariables(includeDirective.arguments, variables ?? {})["if"]) {
485
+ continue;
486
+ }
487
+ }
488
+ const skipDirective = directives?.find((d) => {
489
+ return d.name === "skip";
490
+ });
491
+ if (skipDirective) {
492
+ if (evaluateFragmentVariables(skipDirective.arguments, variables ?? {})["if"]) {
493
+ continue;
494
+ }
495
+ }
496
+ const fieldTarget = visible || ignoreMasking ? target : {};
479
497
  const key = evaluateKey(keyRaw, variables);
480
498
  const { value } = this.storage.get(parent, key);
481
499
  const dt_field = this.staleManager.getFieldTime(parent, key);
@@ -498,16 +516,16 @@ class CacheInternal {
498
516
  partial = true;
499
517
  }
500
518
  if (typeof value === "undefined" || value === null) {
501
- target[attributeName] = null;
519
+ fieldTarget[attributeName] = null;
502
520
  if (typeof value !== "undefined") {
503
521
  hasData = true;
504
522
  }
505
523
  } else if (!fieldSelection) {
506
524
  const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
507
525
  if (fnUnmarshal) {
508
- target[attributeName] = fnUnmarshal(value);
526
+ fieldTarget[attributeName] = fnUnmarshal(value);
509
527
  } else {
510
- target[attributeName] = value;
528
+ fieldTarget[attributeName] = value;
511
529
  }
512
530
  hasData = true;
513
531
  } else if (Array.isArray(value)) {
@@ -516,9 +534,10 @@ class CacheInternal {
516
534
  variables,
517
535
  linkedList: value,
518
536
  stepsFromConnection: nextStep,
519
- ignoreMasking: !!ignoreMasking
537
+ ignoreMasking: !!ignoreMasking,
538
+ fullCheck
520
539
  });
521
- target[attributeName] = listValue.data;
540
+ fieldTarget[attributeName] = listValue.data;
522
541
  if (listValue.partial) {
523
542
  partial = true;
524
543
  }
@@ -534,9 +553,10 @@ class CacheInternal {
534
553
  selection: fieldSelection,
535
554
  variables,
536
555
  stepsFromConnection: nextStep,
537
- ignoreMasking
556
+ ignoreMasking,
557
+ fullCheck
538
558
  });
539
- target[attributeName] = objectFields.data;
559
+ fieldTarget[attributeName] = objectFields.data;
540
560
  if (objectFields.partial) {
541
561
  partial = true;
542
562
  }
@@ -547,7 +567,7 @@ class CacheInternal {
547
567
  hasData = true;
548
568
  }
549
569
  }
550
- if (target[attributeName] === null && !nullable && !embeddedCursor) {
570
+ if (fieldTarget[attributeName] === null && !nullable && !embeddedCursor) {
551
571
  cascadeNull = true;
552
572
  }
553
573
  }
@@ -579,7 +599,8 @@ class CacheInternal {
579
599
  variables,
580
600
  linkedList,
581
601
  stepsFromConnection,
582
- ignoreMasking
602
+ ignoreMasking,
603
+ fullCheck
583
604
  }) {
584
605
  const result = [];
585
606
  let partialData = false;
@@ -592,7 +613,8 @@ class CacheInternal {
592
613
  variables,
593
614
  linkedList: entry,
594
615
  stepsFromConnection,
595
- ignoreMasking
616
+ ignoreMasking,
617
+ fullCheck
596
618
  });
597
619
  result.push(nestedValue.data);
598
620
  if (nestedValue.partial) {
@@ -614,7 +636,8 @@ class CacheInternal {
614
636
  selection: fields,
615
637
  variables,
616
638
  stepsFromConnection,
617
- ignoreMasking
639
+ ignoreMasking,
640
+ fullCheck
618
641
  });
619
642
  result.push(data);
620
643
  if (partial) {
@@ -5,9 +5,6 @@ import { Writable } from '../lib/store';
5
5
  import type { DocumentArtifact, QueryResult, GraphQLObject, SubscriptionSpec, CachePolicies } from '../lib/types';
6
6
  export declare class DocumentStore<_Data extends GraphQLObject, _Input extends Record<string, any>> extends Writable<QueryResult<_Data, _Input>> {
7
7
  #private;
8
- pendingPromise: {
9
- then: (val: any) => void;
10
- } | null;
11
8
  constructor({ artifact, plugins, pipeline, client, cache, initialValue, fetching, }: {
12
9
  artifact: DocumentArtifact;
13
10
  plugins?: ClientHooks[];
@@ -15,7 +15,6 @@ class DocumentStore extends Writable {
15
15
  #plugins;
16
16
  #lastVariables;
17
17
  #lastContext = null;
18
- pendingPromise = null;
19
18
  constructor({
20
19
  artifact,
21
20
  plugins,
@@ -88,7 +87,7 @@ class DocumentStore extends Writable {
88
87
  const draft = context.draft();
89
88
  draft.variables = variables ?? null;
90
89
  context = context.apply(draft, false);
91
- const promise = new Promise((resolve, reject) => {
90
+ return await new Promise((resolve, reject) => {
92
91
  const state = {
93
92
  setup,
94
93
  currentStep: 0,
@@ -97,17 +96,12 @@ class DocumentStore extends Writable {
97
96
  promise: {
98
97
  resolved: false,
99
98
  resolve,
100
- reject,
101
- then: (...args) => promise.then(...args)
99
+ reject
102
100
  },
103
101
  context
104
102
  };
105
- if (this.pendingPromise === null) {
106
- this.pendingPromise = state.promise;
107
- }
108
103
  this.#step("forward", state);
109
104
  });
110
- return await promise;
111
105
  }
112
106
  async cleanup() {
113
107
  for (const plugin of this.#plugins) {
@@ -226,15 +220,16 @@ class DocumentStore extends Writable {
226
220
  value
227
221
  );
228
222
  }
229
- if (!ctx.silenceEcho || value.data !== this.state.data) {
230
- this.set(value);
231
- }
232
223
  if (!ctx.promise.resolved) {
233
224
  ctx.promise.resolve(value);
234
225
  ctx.promise.resolved = true;
235
226
  }
236
227
  this.#lastContext = ctx.context.draft();
237
228
  this.#lastVariables = this.#lastContext.stuff.inputs.marshaled;
229
+ if (ctx.silenceEcho && value.data === this.state.data) {
230
+ return;
231
+ }
232
+ this.set(value);
238
233
  }
239
234
  }
240
235
  class ClientPluginContextWrapper {
@@ -3,7 +3,7 @@ import type { DocumentArtifact, GraphQLObject, NestedList } from '../lib/types';
3
3
  import type { ClientPlugin, ClientHooks } from './documentStore';
4
4
  import { DocumentStore } from './documentStore';
5
5
  import { type FetchParamFn, type ThrowOnErrorParams } from './plugins';
6
- export { DocumentStore, type ClientPlugin, type SendParams } from './documentStore';
6
+ export { DocumentStore, type ClientPlugin } from './documentStore';
7
7
  export { fetch, mutation, query, subscription } from './plugins';
8
8
  type ConstructorArgs = {
9
9
  url: string;