houdini 1.1.3 → 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.
@@ -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) {
@@ -16,7 +16,8 @@ const cachePolicy = ({
16
16
  if (policy !== CachePolicy.NetworkOnly) {
17
17
  const value = localCache.read({
18
18
  selection: artifact.selection,
19
- variables: marshalVariables(ctx)
19
+ variables: marshalVariables(ctx),
20
+ fullCheck: true
20
21
  });
21
22
  const allowed = !value.partial || artifact.kind === ArtifactKind.Query && artifact.partial;
22
23
  if (policy === CachePolicy.CacheOnly) {
@@ -141,6 +141,10 @@ export type SubscriptionSelection = {
141
141
  connection: boolean;
142
142
  type: string;
143
143
  };
144
+ directives?: {
145
+ name: string;
146
+ arguments: ValueMap;
147
+ }[];
144
148
  updates?: string[];
145
149
  visible?: boolean;
146
150
  filters?: Record<string, {