houdini 1.0.11 → 1.1.1-next.0

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 (67) hide show
  1. package/build/cmd-cjs/index.js +659 -330
  2. package/build/cmd-esm/index.js +659 -330
  3. package/build/codegen/generators/artifacts/selection.d.ts +5 -2
  4. package/build/codegen/generators/typescript/inlineType.d.ts +1 -1
  5. package/build/codegen/transforms/{composeQueries.d.ts → collectDefinitions.d.ts} +1 -1
  6. package/build/codegen/transforms/fragmentVariables.d.ts +2 -4
  7. package/build/codegen/transforms/index.d.ts +1 -1
  8. package/build/codegen/utils/flattenSelections.d.ts +2 -2
  9. package/build/codegen-cjs/index.js +604 -326
  10. package/build/codegen-esm/index.js +604 -326
  11. package/build/lib/config.d.ts +10 -1
  12. package/build/lib/deepMerge.d.ts +1 -1
  13. package/build/lib/types.d.ts +1 -0
  14. package/build/lib-cjs/index.js +261 -115
  15. package/build/lib-esm/index.js +260 -115
  16. package/build/runtime/cache/cache.d.ts +17 -6
  17. package/build/runtime/client/documentStore.d.ts +1 -0
  18. package/build/runtime/client/plugins/cache.d.ts +3 -2
  19. package/build/runtime/client/plugins/fragment.d.ts +2 -0
  20. package/build/runtime/client/plugins/index.d.ts +1 -0
  21. package/build/runtime/lib/scalars.d.ts +0 -1
  22. package/build/runtime/lib/types.d.ts +55 -7
  23. package/build/runtime-cjs/cache/cache.d.ts +17 -6
  24. package/build/runtime-cjs/cache/cache.js +89 -21
  25. package/build/runtime-cjs/cache/lists.js +2 -1
  26. package/build/runtime-cjs/cache/subscription.js +11 -2
  27. package/build/runtime-cjs/client/documentStore.d.ts +1 -0
  28. package/build/runtime-cjs/client/documentStore.js +5 -14
  29. package/build/runtime-cjs/client/index.js +2 -1
  30. package/build/runtime-cjs/client/plugins/cache.d.ts +3 -2
  31. package/build/runtime-cjs/client/plugins/cache.js +19 -3
  32. package/build/runtime-cjs/client/plugins/fetch.js +4 -1
  33. package/build/runtime-cjs/client/plugins/fragment.d.ts +2 -0
  34. package/build/runtime-cjs/client/plugins/fragment.js +76 -0
  35. package/build/runtime-cjs/client/plugins/index.d.ts +1 -0
  36. package/build/runtime-cjs/client/plugins/index.js +1 -0
  37. package/build/runtime-cjs/client/plugins/query.js +3 -5
  38. package/build/runtime-cjs/lib/scalars.d.ts +0 -1
  39. package/build/runtime-cjs/lib/scalars.js +2 -43
  40. package/build/runtime-cjs/lib/types.d.ts +55 -7
  41. package/build/runtime-cjs/lib/types.js +5 -2
  42. package/build/runtime-cjs/public/tests/test.js +4 -2
  43. package/build/runtime-esm/cache/cache.d.ts +17 -6
  44. package/build/runtime-esm/cache/cache.js +89 -22
  45. package/build/runtime-esm/cache/lists.js +2 -1
  46. package/build/runtime-esm/cache/subscription.js +11 -2
  47. package/build/runtime-esm/client/documentStore.d.ts +1 -0
  48. package/build/runtime-esm/client/documentStore.js +6 -15
  49. package/build/runtime-esm/client/index.js +3 -1
  50. package/build/runtime-esm/client/plugins/cache.d.ts +3 -2
  51. package/build/runtime-esm/client/plugins/cache.js +19 -3
  52. package/build/runtime-esm/client/plugins/fetch.js +5 -2
  53. package/build/runtime-esm/client/plugins/fragment.d.ts +2 -0
  54. package/build/runtime-esm/client/plugins/fragment.js +46 -0
  55. package/build/runtime-esm/client/plugins/index.d.ts +1 -0
  56. package/build/runtime-esm/client/plugins/index.js +1 -0
  57. package/build/runtime-esm/client/plugins/query.js +3 -5
  58. package/build/runtime-esm/lib/scalars.d.ts +0 -1
  59. package/build/runtime-esm/lib/scalars.js +1 -41
  60. package/build/runtime-esm/lib/types.d.ts +55 -7
  61. package/build/runtime-esm/lib/types.js +3 -1
  62. package/build/runtime-esm/public/tests/test.js +4 -2
  63. package/build/test-cjs/index.js +658 -329
  64. package/build/test-esm/index.js +658 -329
  65. package/build/vite-cjs/index.js +657 -328
  66. package/build/vite-esm/index.js +657 -328
  67. package/package.json +2 -2
@@ -1,8 +1,9 @@
1
1
  import { computeKey } from "../lib";
2
- import { computeID, defaultConfigValues, keyFieldsForType } from "../lib/config";
2
+ import { computeID, defaultConfigValues, keyFieldsForType, getCurrentConfig } from "../lib/config";
3
3
  import { deepEquals } from "../lib/deepEquals";
4
4
  import { flatten } from "../lib/flatten";
5
5
  import { getFieldsForType } from "../lib/selection";
6
+ import { fragmentKey } from "../lib/types";
6
7
  import { GarbageCollector } from "./gc";
7
8
  import { ListManager } from "./lists";
8
9
  import { SchemaManager } from "./schema";
@@ -12,7 +13,7 @@ import { evaluateKey } from "./stuff";
12
13
  import { InMemorySubscriptions } from "./subscription";
13
14
  class Cache {
14
15
  _internal_unstable;
15
- constructor(config) {
16
+ constructor({ disabled, ...config } = {}) {
16
17
  this._internal_unstable = new CacheInternal({
17
18
  cache: this,
18
19
  storage: new InMemoryStorage(),
@@ -20,9 +21,10 @@ class Cache {
20
21
  lists: new ListManager(this, rootID),
21
22
  lifetimes: new GarbageCollector(this),
22
23
  staleManager: new StaleManager(this),
23
- schema: new SchemaManager(this)
24
+ schema: new SchemaManager(this),
25
+ disabled: disabled ?? typeof globalThis.window === "undefined"
24
26
  });
25
- if (config) {
27
+ if (Object.keys(config).length > 0) {
26
28
  this.setConfig(defaultConfigValues(config));
27
29
  }
28
30
  }
@@ -41,7 +43,8 @@ class Cache {
41
43
  this._internal_unstable.getSelection({
42
44
  parent: spec.parentID || rootID,
43
45
  selection: spec.selection,
44
- variables: spec.variables?.() || {}
46
+ variables: spec.variables?.() || {},
47
+ ignoreMasking: false
45
48
  }).data
46
49
  );
47
50
  }
@@ -116,16 +119,13 @@ class Cache {
116
119
  getFieldTime(id, field) {
117
120
  return this._internal_unstable.staleManager.getFieldTime(id, field);
118
121
  }
122
+ config() {
123
+ return this._internal_unstable.config;
124
+ }
119
125
  }
120
126
  class CacheInternal {
121
127
  _disabled = false;
122
- config = defaultConfigValues({
123
- plugins: {
124
- "houdini-svelte": {
125
- client: ""
126
- }
127
- }
128
- });
128
+ _config;
129
129
  storage;
130
130
  subscriptions;
131
131
  lists;
@@ -140,7 +140,9 @@ class CacheInternal {
140
140
  cache,
141
141
  lifetimes,
142
142
  staleManager,
143
- schema
143
+ schema,
144
+ disabled,
145
+ config
144
146
  }) {
145
147
  this.storage = storage;
146
148
  this.subscriptions = subscriptions;
@@ -149,7 +151,8 @@ class CacheInternal {
149
151
  this.lifetimes = lifetimes;
150
152
  this.staleManager = staleManager;
151
153
  this.schema = schema;
152
- this._disabled = typeof globalThis.window === "undefined";
154
+ this._config = config;
155
+ this._disabled = disabled;
153
156
  try {
154
157
  if (process.env.HOUDINI_TEST === "true") {
155
158
  this._disabled = false;
@@ -157,8 +160,11 @@ class CacheInternal {
157
160
  } catch {
158
161
  }
159
162
  }
163
+ get config() {
164
+ return this._config ?? getCurrentConfig();
165
+ }
160
166
  setConfig(config) {
161
- this.config = config;
167
+ this._config = config;
162
168
  }
163
169
  writeSelection({
164
170
  data,
@@ -435,12 +441,24 @@ class CacheInternal {
435
441
  selection,
436
442
  parent = rootID,
437
443
  variables,
438
- stepsFromConnection = null
444
+ stepsFromConnection = null,
445
+ ignoreMasking
439
446
  }) {
440
447
  if (parent === null) {
441
448
  return { data: null, partial: false, stale: false, hasData: true };
442
449
  }
443
450
  const target = {};
451
+ if (selection.fragments) {
452
+ target[fragmentKey] = Object.fromEntries(
453
+ Object.entries(selection.fragments).map(([key, value]) => [
454
+ key,
455
+ {
456
+ parent,
457
+ variables: evaluateFragmentVariables(value, variables ?? {})
458
+ }
459
+ ])
460
+ );
461
+ }
444
462
  let hasData = false;
445
463
  let partial = false;
446
464
  let cascadeNull = false;
@@ -449,8 +467,11 @@ class CacheInternal {
449
467
  let targetSelection = getFieldsForType(selection, typename);
450
468
  for (const [
451
469
  attributeName,
452
- { type, keyRaw, selection: fieldSelection, nullable, list }
470
+ { type, keyRaw, selection: fieldSelection, nullable, list, visible }
453
471
  ] of Object.entries(targetSelection)) {
472
+ if (!visible && !ignoreMasking) {
473
+ continue;
474
+ }
454
475
  const key = evaluateKey(keyRaw, variables);
455
476
  const { value } = this.storage.get(parent, key);
456
477
  const dt_field = this.staleManager.getFieldTime(parent, key);
@@ -490,7 +511,8 @@ class CacheInternal {
490
511
  fields: fieldSelection,
491
512
  variables,
492
513
  linkedList: value,
493
- stepsFromConnection: nextStep
514
+ stepsFromConnection: nextStep,
515
+ ignoreMasking: !!ignoreMasking
494
516
  });
495
517
  target[attributeName] = listValue.data;
496
518
  if (listValue.partial) {
@@ -507,7 +529,8 @@ class CacheInternal {
507
529
  parent: value,
508
530
  selection: fieldSelection,
509
531
  variables,
510
- stepsFromConnection: nextStep
532
+ stepsFromConnection: nextStep,
533
+ ignoreMasking
511
534
  });
512
535
  target[attributeName] = objectFields.data;
513
536
  if (objectFields.partial) {
@@ -551,7 +574,8 @@ class CacheInternal {
551
574
  fields,
552
575
  variables,
553
576
  linkedList,
554
- stepsFromConnection
577
+ stepsFromConnection,
578
+ ignoreMasking
555
579
  }) {
556
580
  const result = [];
557
581
  let partialData = false;
@@ -563,7 +587,8 @@ class CacheInternal {
563
587
  fields,
564
588
  variables,
565
589
  linkedList: entry,
566
- stepsFromConnection
590
+ stepsFromConnection,
591
+ ignoreMasking
567
592
  });
568
593
  result.push(nestedValue.data);
569
594
  if (nestedValue.partial) {
@@ -584,7 +609,8 @@ class CacheInternal {
584
609
  parent: entry,
585
610
  selection: fields,
586
611
  variables,
587
- stepsFromConnection
612
+ stepsFromConnection,
613
+ ignoreMasking
588
614
  });
589
615
  result.push(data);
590
616
  if (partial) {
@@ -687,8 +713,49 @@ class CacheInternal {
687
713
  }
688
714
  }
689
715
  }
716
+ function evaluateFragmentVariables(variables, args) {
717
+ return Object.fromEntries(
718
+ Object.entries(variables).map(([key, value]) => [key, fragmentVariableValue(value, args)])
719
+ );
720
+ }
721
+ function fragmentVariableValue(value, args) {
722
+ if (value.kind === "StringValue") {
723
+ return value.value;
724
+ }
725
+ if (value.kind === "BooleanValue") {
726
+ return value.value;
727
+ }
728
+ if (value.kind === "EnumValue") {
729
+ return value.value;
730
+ }
731
+ if (value.kind === "FloatValue") {
732
+ return parseFloat(value.value);
733
+ }
734
+ if (value.kind === "IntValue") {
735
+ return parseInt(value.value, 10);
736
+ }
737
+ if (value.kind === "NullValue") {
738
+ return null;
739
+ }
740
+ if (value.kind === "Variable") {
741
+ return args[value.name.value];
742
+ }
743
+ if (value.kind === "ListValue") {
744
+ return value.values.map((value2) => fragmentVariableValue(value2, args));
745
+ }
746
+ if (value.kind === "ObjectValue") {
747
+ return value.fields.reduce(
748
+ (obj, field) => ({
749
+ ...obj,
750
+ [field.name.value]: fragmentVariableValue(field.value, args)
751
+ }),
752
+ {}
753
+ );
754
+ }
755
+ }
690
756
  const rootID = "_ROOT_";
691
757
  export {
692
758
  Cache,
759
+ evaluateFragmentVariables,
693
760
  rootID
694
761
  };
@@ -266,7 +266,8 @@ class List {
266
266
  this.cache._internal_unstable.getSelection({
267
267
  parent: spec.parentID || this.manager.rootID,
268
268
  selection: spec.selection,
269
- variables: spec.variables?.() || {}
269
+ variables: spec.variables?.() || {},
270
+ ignoreMasking: false
270
271
  }).data
271
272
  );
272
273
  }
@@ -19,7 +19,17 @@ class InMemorySubscriptions {
19
19
  const __typename = this.cache._internal_unstable.storage.get(parent, "__typename").value;
20
20
  let targetSelection = getFieldsForType(selection, __typename);
21
21
  for (const fieldSelection of Object.values(targetSelection || {})) {
22
- const { keyRaw, selection: innerSelection, type, list, filters } = fieldSelection;
22
+ const {
23
+ keyRaw,
24
+ selection: innerSelection,
25
+ type,
26
+ list,
27
+ filters,
28
+ visible
29
+ } = fieldSelection;
30
+ if (!visible) {
31
+ continue;
32
+ }
23
33
  const key = evaluateKey(keyRaw, variables);
24
34
  let targetSelection2;
25
35
  if (innerSelection) {
@@ -93,7 +103,6 @@ class InMemorySubscriptions {
93
103
  const counts = this.referenceCounts[id][key];
94
104
  counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
95
105
  this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
96
- const { selection: innerSelection } = selection[1]?.[key] ?? {};
97
106
  }
98
107
  registerList({
99
108
  list,
@@ -46,6 +46,7 @@ export type ClientPluginContext = {
46
46
  forceNotify?: boolean;
47
47
  disableWrite?: boolean;
48
48
  disableRead?: boolean;
49
+ disableSubscriptions?: boolean;
49
50
  applyUpdates?: string[];
50
51
  };
51
52
  stuff: App.Stuff;
@@ -1,6 +1,6 @@
1
1
  import { getCurrentConfig } from "../lib/config";
2
2
  import { deepEquals } from "../lib/deepEquals";
3
- import { marshalInputs, unmarshalSelection } from "../lib/scalars";
3
+ import { marshalInputs } from "../lib/scalars";
4
4
  import { Writable } from "../lib/store";
5
5
  import { ArtifactKind } from "../lib/types";
6
6
  import { cachePolicy } from "./plugins";
@@ -159,8 +159,8 @@ class DocumentStore extends Writable {
159
159
  handlers = {
160
160
  ...common,
161
161
  value,
162
- resolve: (ctx2, data2) => {
163
- return common.resolve(ctx2, data2 ?? value);
162
+ resolve: (ctx2, data) => {
163
+ return common.resolve(ctx2, data ?? value);
164
164
  }
165
165
  };
166
166
  } else if (direction === "error") {
@@ -220,25 +220,16 @@ class DocumentStore extends Writable {
220
220
  value
221
221
  );
222
222
  }
223
- let data = value.data;
224
- try {
225
- data = unmarshalSelection(this.#configFile, this.#artifact.selection, data) ?? null;
226
- } catch {
227
- }
228
- const finalValue = {
229
- ...value,
230
- data
231
- };
232
223
  if (!ctx.promise.resolved) {
233
- ctx.promise.resolve(finalValue);
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;
238
- if (ctx.silenceEcho && finalValue.data === this.state.data) {
229
+ if (ctx.silenceEcho && value.data === this.state.data) {
239
230
  return;
240
231
  }
241
- this.set(finalValue);
232
+ this.set(value);
242
233
  }
243
234
  }
244
235
  class ClientPluginContextWrapper {
@@ -4,6 +4,7 @@ import {
4
4
  fetch as fetchPlugin,
5
5
  mutation as mutationPlugin,
6
6
  query as queryPlugin,
7
+ fragment as fragmentPlugin,
7
8
  throwOnError as throwOnErrorPlugin,
8
9
  fetchParams as fetchParamsPlugin
9
10
  } from "./plugins";
@@ -25,7 +26,8 @@ class HoudiniClient {
25
26
  fetchParamsPlugin(fetchParams),
26
27
  pipeline ?? [
27
28
  queryPlugin,
28
- mutationPlugin
29
+ mutationPlugin,
30
+ fragmentPlugin
29
31
  ].concat(
30
32
  plugins ?? [],
31
33
  pluginsFromPlugins,
@@ -1,8 +1,9 @@
1
1
  import cache from '../../cache';
2
- import type { Cache } from '../../cache/cache';
2
+ import { Cache } from '../../cache/cache';
3
3
  import type { ClientPlugin } from '../documentStore';
4
- export declare const cachePolicy: ({ enabled, setFetching, cache: localCache, }: {
4
+ export declare const cachePolicy: ({ enabled, setFetching, cache: localCache, serverSideFallback, }: {
5
5
  enabled: boolean;
6
6
  setFetching: (val: boolean) => void;
7
7
  cache?: Cache | undefined;
8
+ serverSideFallback?: boolean | undefined;
8
9
  }) => ClientPlugin;
@@ -1,9 +1,12 @@
1
1
  import cache from "../../cache";
2
+ import { Cache } from "../../cache/cache";
2
3
  import { ArtifactKind, CachePolicy, DataSource } from "../../lib/types";
4
+ const serverSide = typeof globalThis.window === "undefined";
3
5
  const cachePolicy = ({
4
6
  enabled,
5
7
  setFetching,
6
- cache: localCache = cache
8
+ cache: localCache = cache,
9
+ serverSideFallback = true
7
10
  }) => () => {
8
11
  return {
9
12
  network(ctx, { initialValue, next, resolve, marshalVariables }) {
@@ -54,13 +57,26 @@ const cachePolicy = ({
54
57
  },
55
58
  afterNetwork(ctx, { resolve, value, marshalVariables }) {
56
59
  if (value.source !== DataSource.Cache && enabled && value.data && !ctx.cacheParams?.disableWrite) {
57
- localCache.write({
60
+ const targetCache = serverSide && serverSideFallback ? new Cache({ disabled: false }) : localCache;
61
+ let layer;
62
+ if (!serverSide && ctx.cacheParams?.layer) {
63
+ layer = ctx.cacheParams.layer.id;
64
+ }
65
+ targetCache.write({
58
66
  ...ctx.cacheParams,
59
- layer: ctx.cacheParams?.layer?.id,
67
+ layer,
60
68
  selection: ctx.artifact.selection,
61
69
  data: value.data,
62
70
  variables: marshalVariables(ctx)
63
71
  });
72
+ value = {
73
+ ...value,
74
+ data: targetCache.read({
75
+ selection: ctx.artifact.selection,
76
+ variables: marshalVariables(ctx),
77
+ ignoreMasking: serverSide
78
+ }).data
79
+ };
64
80
  }
65
81
  resolve(ctx, value);
66
82
  }
@@ -1,8 +1,11 @@
1
- import { DataSource } from "../../lib/types";
1
+ import { ArtifactKind, DataSource } from "../../lib/types";
2
2
  const fetch = (target) => {
3
3
  return () => {
4
4
  return {
5
- async network(ctx, { client, resolve, marshalVariables }) {
5
+ async network(ctx, { client, initialValue, resolve, marshalVariables }) {
6
+ if (ctx.artifact.kind === ArtifactKind.Fragment) {
7
+ return resolve(ctx, initialValue);
8
+ }
6
9
  const fetch2 = ctx.fetch ?? globalThis.fetch;
7
10
  const fetchParams = {
8
11
  text: ctx.text,
@@ -0,0 +1,2 @@
1
+ import type { ClientPlugin } from '../documentStore';
2
+ export declare const fragment: ClientPlugin;
@@ -0,0 +1,46 @@
1
+ import cache from "../../cache";
2
+ import { ArtifactKind, DataSource } from "../../lib/types";
3
+ import { documentPlugin } from "../utils";
4
+ const fragment = documentPlugin(ArtifactKind.Fragment, function() {
5
+ let subscriptionSpec = null;
6
+ return {
7
+ start(ctx, { next, resolve, variablesChanged, marshalVariables }) {
8
+ if (!ctx.stuff.parentID) {
9
+ return next(ctx);
10
+ }
11
+ if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
12
+ if (subscriptionSpec) {
13
+ cache.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
14
+ }
15
+ const variables = marshalVariables(ctx);
16
+ subscriptionSpec = {
17
+ rootType: ctx.artifact.rootType,
18
+ selection: ctx.artifact.selection,
19
+ variables: () => variables,
20
+ parentID: ctx.stuff.parentID,
21
+ set: (newValue) => {
22
+ resolve(ctx, {
23
+ data: newValue,
24
+ errors: null,
25
+ fetching: false,
26
+ partial: false,
27
+ stale: false,
28
+ source: DataSource.Cache,
29
+ variables
30
+ });
31
+ }
32
+ };
33
+ cache.subscribe(subscriptionSpec, variables);
34
+ }
35
+ next(ctx);
36
+ },
37
+ cleanup() {
38
+ if (subscriptionSpec) {
39
+ cache.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
40
+ }
41
+ }
42
+ };
43
+ });
44
+ export {
45
+ fragment
46
+ };
@@ -1,6 +1,7 @@
1
1
  export * from './fetch';
2
2
  export * from './cache';
3
3
  export * from './query';
4
+ export * from './fragment';
4
5
  export * from './mutation';
5
6
  export * from './subscription';
6
7
  export * from './throwOnError';
@@ -1,6 +1,7 @@
1
1
  export * from "./fetch";
2
2
  export * from "./cache";
3
3
  export * from "./query";
4
+ export * from "./fragment";
4
5
  export * from "./mutation";
5
6
  export * from "./subscription";
6
7
  export * from "./throwOnError";
@@ -4,7 +4,6 @@ import { documentPlugin } from "../utils";
4
4
  const query = documentPlugin(ArtifactKind.Query, function() {
5
5
  let subscriptionSpec = null;
6
6
  let lastVariables = null;
7
- let artifactName = "";
8
7
  return {
9
8
  start(ctx, { next }) {
10
9
  ctx.variables = {
@@ -14,8 +13,7 @@ const query = documentPlugin(ArtifactKind.Query, function() {
14
13
  next(ctx);
15
14
  },
16
15
  end(ctx, { resolve, marshalVariables, variablesChanged }) {
17
- if (variablesChanged(ctx)) {
18
- artifactName = ctx.artifact.name;
16
+ if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
19
17
  if (subscriptionSpec) {
20
18
  cache.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
21
19
  }
@@ -36,13 +34,13 @@ const query = documentPlugin(ArtifactKind.Query, function() {
36
34
  });
37
35
  }
38
36
  };
39
- cache.subscribe(subscriptionSpec, lastVariables ?? {});
37
+ cache.subscribe(subscriptionSpec, lastVariables);
40
38
  }
41
39
  resolve(ctx);
42
40
  },
43
41
  cleanup() {
44
42
  if (subscriptionSpec) {
45
- cache.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() ?? {});
43
+ cache.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
46
44
  lastVariables = null;
47
45
  }
48
46
  }
@@ -10,6 +10,5 @@ export declare function marshalInputs<T>({ artifact, input, config, rootType, }:
10
10
  rootType?: string;
11
11
  config: ConfigFile;
12
12
  }): {} | null | undefined;
13
- export declare function unmarshalSelection(config: ConfigFile, selection: SubscriptionSelection, data: any): {} | null | undefined;
14
13
  export declare function isScalar(config: ConfigFile, type: string): boolean;
15
14
  export declare function parseScalar(config: ConfigFile, type: string, value?: string): string | number | boolean | undefined;
@@ -75,45 +75,6 @@ function marshalInputs({
75
75
  })
76
76
  );
77
77
  }
78
- function unmarshalSelection(config, selection, data) {
79
- if (data === null || typeof data === "undefined") {
80
- return data;
81
- }
82
- if (Array.isArray(data)) {
83
- return data.map((val) => unmarshalSelection(config, selection, val));
84
- }
85
- const targetSelection = getFieldsForType(selection, data["__typename"]);
86
- return Object.fromEntries(
87
- Object.entries(data).map(([fieldName, value]) => {
88
- const { type, selection: selection2 } = targetSelection[fieldName];
89
- if (!type) {
90
- return [fieldName, value];
91
- }
92
- if (selection2) {
93
- return [
94
- fieldName,
95
- unmarshalSelection(config, selection2, value)
96
- ];
97
- }
98
- if (value === null) {
99
- return [fieldName, value];
100
- }
101
- if (config.scalars?.[type]?.marshal) {
102
- const unmarshalFn = config.scalars[type]?.unmarshal;
103
- if (!unmarshalFn) {
104
- throw new Error(
105
- `scalar type ${type} is missing an \`unmarshal\` function. see https://github.com/AlecAivazis/houdini#%EF%B8%8Fcustom-scalars`
106
- );
107
- }
108
- if (Array.isArray(value)) {
109
- return [fieldName, value.map(unmarshalFn)];
110
- }
111
- return [fieldName, unmarshalFn(value)];
112
- }
113
- return [fieldName, value];
114
- })
115
- );
116
- }
117
78
  function isScalar(config, type) {
118
79
  return ["String", "Boolean", "Float", "ID", "Int"].concat(Object.keys(config.scalars || {})).includes(type);
119
80
  }
@@ -153,6 +114,5 @@ export {
153
114
  isScalar,
154
115
  marshalInputs,
155
116
  marshalSelection,
156
- parseScalar,
157
- unmarshalSelection
117
+ parseScalar
158
118
  };
@@ -24,6 +24,7 @@ declare global {
24
24
  changed: boolean;
25
25
  };
26
26
  optimisticResponse?: GraphQLObject;
27
+ parentID?: string;
27
28
  }
28
29
  }
29
30
  }
@@ -84,7 +85,7 @@ export type BaseCompiledDocument<_Kind extends ArtifactKinds> = {
84
85
  direction: 'forward' | 'backward' | 'both';
85
86
  mode: PaginateModes;
86
87
  };
87
- pluginData?: Record<string, any>;
88
+ pluginData: Record<string, any>;
88
89
  };
89
90
  export type HoudiniFetchContext = {
90
91
  variables: () => {};
@@ -128,6 +129,7 @@ export type GraphQLObject = {
128
129
  };
129
130
  export type GraphQLValue = number | string | boolean | null | GraphQLObject | GraphQLValue[] | undefined;
130
131
  export type SubscriptionSelection = {
132
+ fragments?: Record<string, ValueMap>;
131
133
  fields?: {
132
134
  [fieldName: string]: {
133
135
  type: string;
@@ -140,12 +142,11 @@ export type SubscriptionSelection = {
140
142
  type: string;
141
143
  };
142
144
  updates?: string[];
143
- filters?: {
144
- [key: string]: {
145
- kind: 'Boolean' | 'String' | 'Float' | 'Int' | 'Variable';
146
- value: string | number | boolean;
147
- };
148
- };
145
+ visible?: boolean;
146
+ filters?: Record<string, {
147
+ kind: 'Boolean' | 'String' | 'Float' | 'Int' | 'Variable';
148
+ value: string | number | boolean;
149
+ }>;
149
150
  selection?: SubscriptionSelection;
150
151
  abstract?: boolean;
151
152
  };
@@ -189,4 +190,51 @@ export type RequestPayload<GraphQLObject = any> = {
189
190
  };
190
191
  export type NestedList<_Result = string> = (_Result | null | NestedList<_Result>)[];
191
192
  export type ValueOf<Parent> = Parent[keyof Parent];
193
+ export declare const fragmentKey = " $fragments";
194
+ export type ValueNode = VariableNode | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ListValueNode | ObjectValueNode;
195
+ export type ValueMap = Record<string, ValueNode>;
196
+ interface IntValueNode {
197
+ readonly kind: 'IntValue';
198
+ readonly value: string;
199
+ }
200
+ interface FloatValueNode {
201
+ readonly kind: 'FloatValue';
202
+ readonly value: string;
203
+ }
204
+ interface StringValueNode {
205
+ readonly kind: 'StringValue';
206
+ readonly value: string;
207
+ }
208
+ interface BooleanValueNode {
209
+ readonly kind: 'BooleanValue';
210
+ readonly value: boolean;
211
+ }
212
+ interface NullValueNode {
213
+ readonly kind: 'NullValue';
214
+ }
215
+ interface EnumValueNode {
216
+ readonly kind: 'EnumValue';
217
+ readonly value: string;
218
+ }
219
+ interface ListValueNode {
220
+ readonly kind: 'ListValue';
221
+ readonly values: ReadonlyArray<ValueNode>;
222
+ }
223
+ interface ObjectValueNode {
224
+ readonly kind: 'ObjectValue';
225
+ readonly fields: ReadonlyArray<ObjectFieldNode>;
226
+ }
227
+ interface ObjectFieldNode {
228
+ readonly kind: 'ObjectField';
229
+ readonly name: NameNode;
230
+ readonly value: ValueNode;
231
+ }
232
+ interface NameNode {
233
+ readonly kind: 'Name';
234
+ readonly value: string;
235
+ }
236
+ interface VariableNode {
237
+ readonly kind: 'Variable';
238
+ readonly name: NameNode;
239
+ }
192
240
  export {};