houdini 1.0.0-next.8 → 1.0.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 (92) hide show
  1. package/README.md +4 -1
  2. package/build/cmd-cjs/index.js +2325 -121
  3. package/build/cmd-esm/index.js +2325 -121
  4. package/build/codegen/generators/runtime/runtimeConfig.d.ts +7 -0
  5. package/build/codegen/generators/typescript/typeReference.d.ts +4 -2
  6. package/build/codegen/generators/typescript/types.d.ts +0 -1
  7. package/build/codegen/utils/flattenSelections.d.ts +1 -1
  8. package/build/codegen-cjs/index.js +2919 -689
  9. package/build/codegen-esm/index.js +2919 -689
  10. package/build/lib/config.d.ts +4 -6
  11. package/build/lib/types.d.ts +18 -15
  12. package/build/lib-cjs/index.js +3159 -171
  13. package/build/lib-esm/index.js +3152 -171
  14. package/build/runtime/cache/storage.d.ts +18 -15
  15. package/build/runtime/client/documentStore.d.ts +15 -13
  16. package/build/runtime/client/index.d.ts +1 -1
  17. package/build/runtime/client/plugins/cache.d.ts +1 -1
  18. package/build/runtime/client/plugins/fetch.d.ts +1 -1
  19. package/build/runtime/client/plugins/fetchParams.d.ts +1 -1
  20. package/build/runtime/client/plugins/mutation.d.ts +1 -1
  21. package/build/runtime/client/plugins/query.d.ts +1 -1
  22. package/build/runtime/client/plugins/subscription.d.ts +1 -1
  23. package/build/runtime/client/plugins/throwOnError.d.ts +1 -1
  24. package/build/runtime/client/utils/documentPlugins.d.ts +2 -2
  25. package/build/runtime/imports/pluginConfig.d.ts +3 -0
  26. package/build/runtime/lib/config.d.ts +2 -2
  27. package/build/runtime/lib/scalars.d.ts +1 -1
  28. package/build/runtime/lib/types.d.ts +42 -42
  29. package/build/runtime-cjs/cache/storage.d.ts +18 -15
  30. package/build/runtime-cjs/cache/storage.js +9 -11
  31. package/build/runtime-cjs/client/documentStore.d.ts +15 -13
  32. package/build/runtime-cjs/client/documentStore.js +11 -8
  33. package/build/runtime-cjs/client/index.d.ts +1 -1
  34. package/build/runtime-cjs/client/index.js +16 -13
  35. package/build/runtime-cjs/client/plugins/cache.d.ts +1 -1
  36. package/build/runtime-cjs/client/plugins/cache.js +6 -6
  37. package/build/runtime-cjs/client/plugins/fetch.d.ts +1 -1
  38. package/build/runtime-cjs/client/plugins/fetch.js +9 -9
  39. package/build/runtime-cjs/client/plugins/fetchParams.d.ts +1 -1
  40. package/build/runtime-cjs/client/plugins/fetchParams.js +3 -3
  41. package/build/runtime-cjs/client/plugins/mutation.d.ts +1 -1
  42. package/build/runtime-cjs/client/plugins/mutation.js +3 -3
  43. package/build/runtime-cjs/client/plugins/query.d.ts +1 -1
  44. package/build/runtime-cjs/client/plugins/query.js +4 -4
  45. package/build/runtime-cjs/client/plugins/subscription.d.ts +1 -1
  46. package/build/runtime-cjs/client/plugins/subscription.js +5 -5
  47. package/build/runtime-cjs/client/plugins/throwOnError.d.ts +1 -1
  48. package/build/runtime-cjs/client/plugins/throwOnError.js +3 -3
  49. package/build/runtime-cjs/client/utils/documentPlugins.d.ts +2 -2
  50. package/build/runtime-cjs/imports/pluginConfig.d.ts +3 -0
  51. package/build/runtime-cjs/imports/pluginConfig.js +27 -0
  52. package/build/runtime-cjs/lib/config.d.ts +2 -2
  53. package/build/runtime-cjs/lib/config.js +11 -1
  54. package/build/runtime-cjs/lib/scalars.d.ts +1 -1
  55. package/build/runtime-cjs/lib/scalars.js +13 -2
  56. package/build/runtime-cjs/lib/types.d.ts +42 -42
  57. package/build/runtime-cjs/lib/types.js +26 -30
  58. package/build/runtime-esm/cache/storage.d.ts +18 -15
  59. package/build/runtime-esm/cache/storage.js +9 -11
  60. package/build/runtime-esm/client/documentStore.d.ts +15 -13
  61. package/build/runtime-esm/client/documentStore.js +12 -9
  62. package/build/runtime-esm/client/index.d.ts +1 -1
  63. package/build/runtime-esm/client/index.js +13 -10
  64. package/build/runtime-esm/client/plugins/cache.d.ts +1 -1
  65. package/build/runtime-esm/client/plugins/cache.js +5 -5
  66. package/build/runtime-esm/client/plugins/fetch.d.ts +1 -1
  67. package/build/runtime-esm/client/plugins/fetch.js +8 -8
  68. package/build/runtime-esm/client/plugins/fetchParams.d.ts +1 -1
  69. package/build/runtime-esm/client/plugins/fetchParams.js +2 -2
  70. package/build/runtime-esm/client/plugins/mutation.d.ts +1 -1
  71. package/build/runtime-esm/client/plugins/mutation.js +2 -2
  72. package/build/runtime-esm/client/plugins/query.d.ts +1 -1
  73. package/build/runtime-esm/client/plugins/query.js +3 -3
  74. package/build/runtime-esm/client/plugins/subscription.d.ts +1 -1
  75. package/build/runtime-esm/client/plugins/subscription.js +4 -4
  76. package/build/runtime-esm/client/plugins/throwOnError.d.ts +1 -1
  77. package/build/runtime-esm/client/plugins/throwOnError.js +2 -2
  78. package/build/runtime-esm/client/utils/documentPlugins.d.ts +2 -2
  79. package/build/runtime-esm/imports/pluginConfig.d.ts +3 -0
  80. package/build/runtime-esm/imports/pluginConfig.js +5 -0
  81. package/build/runtime-esm/lib/config.d.ts +2 -2
  82. package/build/runtime-esm/lib/config.js +11 -1
  83. package/build/runtime-esm/lib/scalars.d.ts +1 -1
  84. package/build/runtime-esm/lib/scalars.js +13 -2
  85. package/build/runtime-esm/lib/types.d.ts +42 -42
  86. package/build/runtime-esm/lib/types.js +26 -30
  87. package/build/test-cjs/index.js +2302 -98
  88. package/build/test-esm/index.js +2302 -98
  89. package/build/vite/houdini.d.ts +2 -0
  90. package/build/vite-cjs/index.js +2328 -122
  91. package/build/vite-esm/index.js +2328 -122
  92. package/package.json +2 -2
@@ -7,7 +7,7 @@ export declare class InMemoryStorage {
7
7
  get layerCount(): number;
8
8
  get nextRank(): number;
9
9
  createLayer(optimistic?: boolean): Layer;
10
- insert(id: string, field: string, location: OperationLocation, target: string): void;
10
+ insert(id: string, field: string, location: OperationLocations, target: string): void;
11
11
  remove(id: string, field: string, target: string): void;
12
12
  delete(id: string): void;
13
13
  deleteField(id: string, field: string): void;
@@ -47,7 +47,7 @@ export declare class Layer {
47
47
  removeUndefinedFields(): void;
48
48
  delete(id: string): void;
49
49
  deleteField(id: string, field: string): void;
50
- insert(id: string, field: string, where: OperationLocation, target: string): void;
50
+ insert(id: string, field: string, where: OperationLocations, target: string): void;
51
51
  remove(id: string, field: string, target: string): void;
52
52
  writeLayer(layer: Layer): void;
53
53
  private addFieldOperation;
@@ -71,28 +71,31 @@ type OperationMap = {
71
71
  };
72
72
  type NestedList<_Result = string> = (_Result | null | NestedList<_Result>)[];
73
73
  type InsertOperation = {
74
- kind: OperationKind.insert;
75
- location: OperationLocation;
74
+ kind: 'insert';
75
+ location: OperationLocations;
76
76
  id: string;
77
77
  };
78
78
  type RemoveOperation = {
79
- kind: OperationKind.remove;
79
+ kind: 'remove';
80
80
  id: string;
81
81
  };
82
82
  type DeleteOperation = {
83
- kind: OperationKind.delete;
83
+ kind: 'delete';
84
84
  target: string;
85
85
  };
86
86
  type ListOperation = InsertOperation | RemoveOperation;
87
87
  type Operation = ListOperation | DeleteOperation;
88
- export declare enum OperationLocation {
89
- start = "start",
90
- end = "end"
91
- }
92
- export declare enum OperationKind {
93
- delete = "delete",
94
- insert = "insert",
95
- remove = "remove"
96
- }
88
+ type ValuesOf<Target> = Target[keyof Target];
89
+ export declare const OperationLocation: {
90
+ readonly start: "start";
91
+ readonly end: "end";
92
+ };
93
+ export type OperationLocations = ValuesOf<typeof OperationLocation>;
94
+ export declare const OperationKind: {
95
+ readonly delete: "delete";
96
+ readonly insert: "insert";
97
+ readonly remove: "remove";
98
+ };
99
+ export type OperationKinds = ValuesOf<typeof OperationKind>;
97
100
  export type LayerID = number;
98
101
  export {};
@@ -350,17 +350,15 @@ function isInsertOperation(value) {
350
350
  function isRemoveOperation(value) {
351
351
  return !!value && value.kind === OperationKind.remove;
352
352
  }
353
- var OperationLocation = /* @__PURE__ */ ((OperationLocation2) => {
354
- OperationLocation2["start"] = "start";
355
- OperationLocation2["end"] = "end";
356
- return OperationLocation2;
357
- })(OperationLocation || {});
358
- var OperationKind = /* @__PURE__ */ ((OperationKind2) => {
359
- OperationKind2["delete"] = "delete";
360
- OperationKind2["insert"] = "insert";
361
- OperationKind2["remove"] = "remove";
362
- return OperationKind2;
363
- })(OperationKind || {});
353
+ const OperationLocation = {
354
+ start: "start",
355
+ end: "end"
356
+ };
357
+ const OperationKind = {
358
+ delete: "delete",
359
+ insert: "insert",
360
+ remove: "remove"
361
+ };
364
362
  export {
365
363
  InMemoryStorage,
366
364
  Layer,
@@ -2,7 +2,7 @@ import type { HoudiniClient } from '.';
2
2
  import type { Layer } from '../cache/storage';
3
3
  import type { ConfigFile } from '../lib/config';
4
4
  import { Writable } from '../lib/store';
5
- import type { CachePolicy, DocumentArtifact, QueryResult, GraphQLObject, SubscriptionSpec } from '../lib/types';
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
8
  constructor({ artifact, plugins, pipeline, client, cache, initialValue, fetching, }: {
@@ -14,16 +14,7 @@ export declare class DocumentStore<_Data extends GraphQLObject, _Input extends R
14
14
  initialValue?: _Data | null;
15
15
  fetching?: boolean;
16
16
  });
17
- send({ metadata, session, fetch, variables, policy, stuff, cacheParams, setup, }?: {
18
- fetch?: Fetch;
19
- variables?: Record<string, any> | null;
20
- metadata?: App.Metadata | null;
21
- session?: App.Session | null;
22
- policy?: CachePolicy;
23
- stuff?: Partial<App.Stuff>;
24
- cacheParams?: ClientPluginContext['cacheParams'];
25
- setup?: boolean;
26
- }): Promise<QueryResult<_Data, _Input>>;
17
+ send({ metadata, session, fetch, variables, policy, stuff, cacheParams, setup, silenceEcho, }?: SendParams): Promise<QueryResult<_Data, _Input>>;
27
18
  }
28
19
  declare function marshalVariables<_Data extends GraphQLObject, _Input extends {}>(ctx: ClientPluginContext): Record<string, any>;
29
20
  export type ClientPlugin = () => ClientHooks | null | (ClientHooks | ClientPlugin | null)[];
@@ -42,9 +33,9 @@ export type ClientPluginContext = {
42
33
  text: string;
43
34
  hash: string;
44
35
  artifact: DocumentArtifact;
45
- policy?: CachePolicy;
36
+ policy?: CachePolicies;
46
37
  fetch?: Fetch;
47
- variables?: Record<string, any>;
38
+ variables?: Record<string, any> | null;
48
39
  metadata?: App.Metadata | null;
49
40
  session?: App.Session | null;
50
41
  fetchParams?: RequestInit;
@@ -85,4 +76,15 @@ export type ClientPluginExitHandlers = Omit<ClientPluginEnterHandlers, 'resolve'
85
76
  export type ClientPluginErrorHandlers = ClientPluginEnterHandlers & {
86
77
  error: unknown;
87
78
  };
79
+ export type SendParams = {
80
+ fetch?: Fetch;
81
+ variables?: Record<string, any> | null;
82
+ metadata?: App.Metadata | null;
83
+ session?: App.Session | null;
84
+ policy?: CachePolicies;
85
+ stuff?: Partial<App.Stuff>;
86
+ cacheParams?: ClientPluginContext['cacheParams'];
87
+ setup?: boolean;
88
+ silenceEcho?: boolean;
89
+ };
88
90
  export {};
@@ -3,7 +3,7 @@ import { deepEquals } from "../lib/deepEquals";
3
3
  import { marshalInputs, unmarshalSelection } from "../lib/scalars";
4
4
  import { Writable } from "../lib/store";
5
5
  import { ArtifactKind } from "../lib/types";
6
- import { cachePolicyPlugin } from "./plugins";
6
+ import { cachePolicy } from "./plugins";
7
7
  const steps = {
8
8
  forward: ["start", "beforeNetwork", "network"],
9
9
  backwards: ["end", "afterNetwork"]
@@ -24,9 +24,7 @@ class DocumentStore extends Writable {
24
24
  initialValue,
25
25
  fetching
26
26
  }) {
27
- if (fetching === void 0) {
28
- fetching = artifact.kind === ArtifactKind.Query;
29
- }
27
+ fetching ??= artifact.kind === ArtifactKind.Query;
30
28
  const initialState = {
31
29
  data: initialValue ?? null,
32
30
  errors: null,
@@ -49,7 +47,7 @@ class DocumentStore extends Writable {
49
47
  this.#lastVariables = null;
50
48
  this.#configFile = getCurrentConfig();
51
49
  this.#plugins = pipeline ?? [
52
- cachePolicyPlugin({
50
+ cachePolicy({
53
51
  enabled: cache,
54
52
  setFetching: (fetching2) => this.update((state) => ({ ...state, fetching: fetching2 }))
55
53
  })(),
@@ -64,14 +62,15 @@ class DocumentStore extends Writable {
64
62
  policy,
65
63
  stuff,
66
64
  cacheParams,
67
- setup = false
65
+ setup = false,
66
+ silenceEcho = false
68
67
  } = {}) {
69
68
  let context = new ClientPluginContextWrapper({
70
69
  config: this.#configFile,
71
70
  text: this.#artifact.raw,
72
71
  hash: this.#artifact.hash,
73
72
  policy: policy ?? this.#artifact.policy,
74
- variables: {},
73
+ variables: null,
75
74
  metadata,
76
75
  session,
77
76
  fetch,
@@ -88,13 +87,14 @@ class DocumentStore extends Writable {
88
87
  cacheParams
89
88
  });
90
89
  const draft = context.draft();
91
- draft.variables = variables ?? {};
90
+ draft.variables = variables ?? null;
92
91
  context = context.apply(draft, false);
93
92
  return await new Promise((resolve, reject) => {
94
93
  const state = {
95
94
  setup,
96
95
  currentStep: 0,
97
96
  index: 0,
97
+ silenceEcho,
98
98
  promise: {
99
99
  resolved: false,
100
100
  resolve,
@@ -232,6 +232,9 @@ class DocumentStore extends Writable {
232
232
  }
233
233
  this.#lastContext = ctx.context.draft();
234
234
  this.#lastVariables = this.#lastContext.stuff.inputs.marshaled;
235
+ if (ctx.silenceEcho && finalValue.data === this.state.data) {
236
+ return;
237
+ }
235
238
  this.set(finalValue);
236
239
  }
237
240
  }
@@ -262,7 +265,7 @@ class ClientPluginContextWrapper {
262
265
  ctx.stuff = val;
263
266
  },
264
267
  get variables() {
265
- return ctx.variables ?? {};
268
+ return ctx.variables ?? null;
266
269
  },
267
270
  set variables(val) {
268
271
  Object.assign(ctx, applyVariables(ctx, { variables: val }));
@@ -4,7 +4,7 @@ import type { ClientPlugin, ClientHooks } from './documentStore';
4
4
  import { DocumentStore } from './documentStore';
5
5
  import { type FetchParamFn, type ThrowOnErrorParams } from './plugins';
6
6
  export { DocumentStore, type ClientPlugin } from './documentStore';
7
- export { fetchPlugin, mutationPlugin, queryPlugin, subscriptionPlugin } from './plugins';
7
+ export { fetch, mutation, query, subscription } from './plugins';
8
8
  type ConstructorArgs = {
9
9
  url: string;
10
10
  fetchParams?: FetchParamFn;
@@ -1,15 +1,15 @@
1
1
  import { flatten } from "../lib/flatten";
2
2
  import { DocumentStore } from "./documentStore";
3
3
  import {
4
- fetchParamsPlugin,
5
- fetchPlugin,
6
- mutationPlugin,
7
- queryPlugin,
8
- throwOnErrorPlugin
4
+ fetch as fetchPlugin,
5
+ mutation as mutationPlugin,
6
+ query as queryPlugin,
7
+ throwOnError as throwOnErrorPlugin,
8
+ fetchParams as fetchParamsPlugin
9
9
  } from "./plugins";
10
10
  import pluginsFromPlugins from "./plugins/injectedPlugins";
11
11
  import { DocumentStore as DocumentStore2 } from "./documentStore";
12
- import { fetchPlugin as fetchPlugin2, mutationPlugin as mutationPlugin2, queryPlugin as queryPlugin2, subscriptionPlugin } from "./plugins";
12
+ import { fetch, mutation, query, subscription } from "./plugins";
13
13
  class HoudiniClient {
14
14
  url;
15
15
  #plugins;
@@ -53,6 +53,9 @@ class HoudiniClient {
53
53
  }
54
54
  function createPluginHooks(plugins) {
55
55
  return plugins.reduce((hooks, plugin) => {
56
+ if (typeof plugin !== "function") {
57
+ throw new Error("Encountered client plugin that's not a function");
58
+ }
56
59
  const result = plugin();
57
60
  if (!result) {
58
61
  return hooks;
@@ -76,8 +79,8 @@ export {
76
79
  DocumentStore2 as DocumentStore,
77
80
  HoudiniClient,
78
81
  createPluginHooks,
79
- fetchPlugin2 as fetchPlugin,
80
- mutationPlugin2 as mutationPlugin,
81
- queryPlugin2 as queryPlugin,
82
- subscriptionPlugin
82
+ fetch,
83
+ mutation,
84
+ query,
85
+ subscription
83
86
  };
@@ -1,7 +1,7 @@
1
1
  import cache from '../../cache';
2
2
  import type { Cache } from '../../cache/cache';
3
3
  import type { ClientPlugin } from '../documentStore';
4
- export declare const cachePolicyPlugin: ({ enabled, setFetching, cache: localCache, }: {
4
+ export declare const cachePolicy: ({ enabled, setFetching, cache: localCache, }: {
5
5
  enabled: boolean;
6
6
  setFetching: (val: boolean) => void;
7
7
  cache?: Cache | undefined;
@@ -1,12 +1,12 @@
1
1
  import cache from "../../cache";
2
2
  import { ArtifactKind, CachePolicy, DataSource } from "../../lib/types";
3
- const cachePolicyPlugin = ({
3
+ const cachePolicy = ({
4
4
  enabled,
5
5
  setFetching,
6
6
  cache: localCache = cache
7
7
  }) => () => {
8
8
  return {
9
- network(ctx, { next, resolve, marshalVariables }) {
9
+ network(ctx, { initialValue, next, resolve, marshalVariables }) {
10
10
  const { policy, artifact } = ctx;
11
11
  let useCache = false;
12
12
  if (enabled && artifact.kind === ArtifactKind.Query && !ctx.cacheParams?.disableRead) {
@@ -20,10 +20,10 @@ const cachePolicyPlugin = ({
20
20
  return resolve(ctx, {
21
21
  fetching: false,
22
22
  variables: ctx.variables ?? null,
23
- data: value.data,
23
+ data: allowed ? value.data : initialValue.data,
24
24
  errors: null,
25
25
  source: DataSource.Cache,
26
- partial: value.partial,
26
+ partial: allowed ? value.partial : false,
27
27
  stale: value.stale
28
28
  });
29
29
  }
@@ -67,5 +67,5 @@ const cachePolicyPlugin = ({
67
67
  };
68
68
  };
69
69
  export {
70
- cachePolicyPlugin
70
+ cachePolicy
71
71
  };
@@ -1,6 +1,6 @@
1
1
  import type { RequestPayload } from '../../lib/types';
2
2
  import type { ClientPlugin } from '../documentStore';
3
- export declare const fetchPlugin: (target?: RequestHandler | string) => ClientPlugin;
3
+ export declare const fetch: (target?: RequestHandler | string) => ClientPlugin;
4
4
  export type FetchContext = {
5
5
  fetch: typeof globalThis.fetch;
6
6
  metadata?: App.Metadata | null;
@@ -1,9 +1,9 @@
1
1
  import { DataSource } from "../../lib/types";
2
- const fetchPlugin = (target) => {
2
+ const fetch = (target) => {
3
3
  return () => {
4
4
  return {
5
5
  async network(ctx, { client, resolve, marshalVariables }) {
6
- const fetch = ctx.fetch ?? globalThis.fetch;
6
+ const fetch2 = ctx.fetch ?? globalThis.fetch;
7
7
  const fetchParams = {
8
8
  text: ctx.text,
9
9
  hash: ctx.hash,
@@ -20,7 +20,7 @@ const fetchPlugin = (target) => {
20
20
  const result = await fetchFn({
21
21
  fetch: (url, args) => {
22
22
  const newArgs = handleMultipart(fetchParams, args) ?? args;
23
- return fetch(url, newArgs);
23
+ return fetch2(url, newArgs);
24
24
  },
25
25
  metadata: ctx.metadata,
26
26
  session: ctx.session || {},
@@ -28,7 +28,7 @@ const fetchPlugin = (target) => {
28
28
  });
29
29
  resolve(ctx, {
30
30
  fetching: false,
31
- variables: ctx.variables ?? null,
31
+ variables: ctx.variables ?? {},
32
32
  data: result.data,
33
33
  errors: !result.errors || result.errors.length === 0 ? null : result.errors,
34
34
  partial: false,
@@ -42,11 +42,11 @@ const fetchPlugin = (target) => {
42
42
  const defaultFetch = (url, params) => {
43
43
  if (!url) {
44
44
  throw new Error(
45
- "Could not find configured client url. Please specify one in your houdini.config.js file."
45
+ "Could not find configured client url. Please specify one in your HoudiniClient constructor."
46
46
  );
47
47
  }
48
- return async ({ fetch, text, variables }) => {
49
- const result = await fetch(url, {
48
+ return async ({ fetch: fetch2, text, variables }) => {
49
+ const result = await fetch2(url, {
50
50
  method: "POST",
51
51
  body: JSON.stringify({ query: text, variables }),
52
52
  ...params,
@@ -147,6 +147,6 @@ function isPlainObject(value) {
147
147
  }
148
148
  export {
149
149
  extractFiles,
150
- fetchPlugin,
150
+ fetch,
151
151
  isExtractableFile
152
152
  };
@@ -1,7 +1,7 @@
1
1
  import type { DocumentArtifact } from '../../lib/types';
2
2
  import type { ClientPlugin, ClientPluginContext } from '../documentStore';
3
3
  export type FetchParamFn = (ctx: FetchParamsInput) => Required<ClientPluginContext>['fetchParams'];
4
- export declare const fetchParamsPlugin: (fn?: FetchParamFn) => ClientPlugin;
4
+ export declare const fetchParams: (fn?: FetchParamFn) => ClientPlugin;
5
5
  export type FetchParamsInput = Pick<ClientPluginContext, 'config' | 'policy' | 'variables' | 'metadata' | 'session' | 'stuff'> & {
6
6
  text: string;
7
7
  hash: string;
@@ -1,4 +1,4 @@
1
- const fetchParamsPlugin = (fn = () => ({})) => () => ({
1
+ const fetchParams = (fn = () => ({})) => () => ({
2
2
  beforeNetwork(ctx, { next, marshalVariables }) {
3
3
  next({
4
4
  ...ctx,
@@ -17,5 +17,5 @@ const fetchParamsPlugin = (fn = () => ({})) => () => ({
17
17
  }
18
18
  });
19
19
  export {
20
- fetchParamsPlugin
20
+ fetchParams
21
21
  };
@@ -1 +1 @@
1
- export declare const mutationPlugin: import("..").ClientPlugin;
1
+ export declare const mutation: import("..").ClientPlugin;
@@ -2,7 +2,7 @@ import cache from "../../cache";
2
2
  import { marshalSelection } from "../../lib/scalars";
3
3
  import { ArtifactKind } from "../../lib/types";
4
4
  import { documentPlugin } from "../utils";
5
- const mutationPlugin = documentPlugin(ArtifactKind.Mutation, () => {
5
+ const mutation = documentPlugin(ArtifactKind.Mutation, () => {
6
6
  return {
7
7
  async start(ctx, { next, marshalVariables }) {
8
8
  const layer = cache._internal_unstable.storage.createLayer(true);
@@ -52,5 +52,5 @@ const mutationPlugin = documentPlugin(ArtifactKind.Mutation, () => {
52
52
  };
53
53
  });
54
54
  export {
55
- mutationPlugin
55
+ mutation
56
56
  };
@@ -1,2 +1,2 @@
1
1
  import type { ClientPlugin } from '../documentStore';
2
- export declare const queryPlugin: ClientPlugin;
2
+ export declare const query: ClientPlugin;
@@ -1,7 +1,7 @@
1
1
  import cache from "../../cache";
2
2
  import { ArtifactKind, DataSource } from "../../lib/types";
3
3
  import { documentPlugin } from "../utils";
4
- const queryPlugin = documentPlugin(ArtifactKind.Query, function() {
4
+ const query = documentPlugin(ArtifactKind.Query, function() {
5
5
  let subscriptionSpec = null;
6
6
  let lastVariables = null;
7
7
  let artifactName = "";
@@ -32,7 +32,7 @@ const queryPlugin = documentPlugin(ArtifactKind.Query, function() {
32
32
  partial: false,
33
33
  stale: false,
34
34
  source: DataSource.Cache,
35
- variables: ctx.variables ?? null
35
+ variables: ctx.variables ?? {}
36
36
  });
37
37
  }
38
38
  };
@@ -49,5 +49,5 @@ const queryPlugin = documentPlugin(ArtifactKind.Query, function() {
49
49
  };
50
50
  });
51
51
  export {
52
- queryPlugin
52
+ query
53
53
  };
@@ -1,5 +1,5 @@
1
1
  import type { ClientPluginContext } from '../documentStore';
2
- export declare function subscriptionPlugin(factory: SubscriptionHandler): import("../documentStore").ClientPlugin;
2
+ export declare function subscription(factory: SubscriptionHandler): import("../documentStore").ClientPlugin;
3
3
  export type SubscriptionHandler = (ctx: ClientPluginContext) => {
4
4
  subscribe: (payload: {
5
5
  query: string;
@@ -1,7 +1,7 @@
1
1
  import { deepEquals } from "../../lib/deepEquals";
2
2
  import { ArtifactKind, DataSource } from "../../lib/types";
3
3
  import { documentPlugin } from "../utils";
4
- function subscriptionPlugin(factory) {
4
+ function subscription(factory) {
5
5
  return documentPlugin(ArtifactKind.Subscription, () => {
6
6
  let clearSubscription = null;
7
7
  let socketClient = null;
@@ -45,7 +45,7 @@ function subscriptionPlugin(factory) {
45
45
  partial: true,
46
46
  stale: false,
47
47
  source: DataSource.Network,
48
- variables: ctx.variables ?? null
48
+ variables: ctx.variables ?? {}
49
49
  });
50
50
  },
51
51
  error(data) {
@@ -57,7 +57,7 @@ function subscriptionPlugin(factory) {
57
57
  data: null,
58
58
  errors: [data],
59
59
  fetching: false,
60
- variables: ctx.variables ?? null
60
+ variables: ctx.variables ?? {}
61
61
  });
62
62
  },
63
63
  complete() {
@@ -72,5 +72,5 @@ function subscriptionPlugin(factory) {
72
72
  });
73
73
  }
74
74
  export {
75
- subscriptionPlugin
75
+ subscription
76
76
  };
@@ -4,4 +4,4 @@ export type ThrowOnErrorParams = {
4
4
  operations: ('all' | 'query' | 'mutation' | 'subscription')[];
5
5
  error?: (errors: NonNullable<QueryResult<any, any>['errors']>) => unknown;
6
6
  };
7
- export declare const throwOnErrorPlugin: ({ operations, error }: ThrowOnErrorParams) => ClientPlugin;
7
+ export declare const throwOnError: ({ operations, error }: ThrowOnErrorParams) => ClientPlugin;
@@ -1,5 +1,5 @@
1
1
  import { ArtifactKind } from "../../lib";
2
- const throwOnErrorPlugin = ({ operations, error }) => () => {
2
+ const throwOnError = ({ operations, error }) => () => {
3
3
  const all = operations.includes("all");
4
4
  const throwOnKind = (kind) => all || {
5
5
  [ArtifactKind.Query]: operations.includes("query"),
@@ -19,5 +19,5 @@ const throwOnErrorPlugin = ({ operations, error }) => () => {
19
19
  };
20
20
  const defaultErrorFn = async (errors) => new Error(errors.map((error) => error.message).join(". ") + ".");
21
21
  export {
22
- throwOnErrorPlugin
22
+ throwOnError
23
23
  };
@@ -1,3 +1,3 @@
1
- import type { ArtifactKind } from '../../lib/types';
1
+ import type { ArtifactKinds } from '../../lib/types';
2
2
  import type { ClientPlugin, ClientHooks } from '../documentStore';
3
- export declare const documentPlugin: (kind: ArtifactKind, source: () => ClientHooks) => ClientPlugin;
3
+ export declare const documentPlugin: (kind: ArtifactKinds, source: () => ClientHooks) => ClientPlugin;
@@ -0,0 +1,3 @@
1
+ import type { ConfigFile } from '../lib/config';
2
+ declare const configs: ((old: ConfigFile) => ConfigFile)[];
3
+ export default configs;
@@ -0,0 +1,5 @@
1
+ const configs = [];
2
+ var pluginConfig_default = configs;
3
+ export {
4
+ pluginConfig_default as default
5
+ };
@@ -1,5 +1,5 @@
1
1
  import type { GraphQLSchema } from 'graphql';
2
- import type { CachePolicy } from './types';
2
+ import type { CachePolicies } from './types';
3
3
  export declare function getMockConfig(): ConfigFile | null;
4
4
  export declare function setMockConfig(config: ConfigFile | null): void;
5
5
  export declare function defaultConfigValues(file: ConfigFile): ConfigFile;
@@ -50,7 +50,7 @@ export type ConfigFile = {
50
50
  /**
51
51
  * The default cache policy to use for queries. For more information: https://www.houdinigraphql.com/guides/caching-data
52
52
  */
53
- defaultCachePolicy?: CachePolicy;
53
+ defaultCachePolicy?: CachePolicies;
54
54
  /**
55
55
  * Specifies whether or not the cache should always use partial data. For more information: https://www.houdinigraphql.com/guides/caching-data#partial-data
56
56
  */
@@ -1,4 +1,5 @@
1
1
  import config from "../imports/config";
2
+ import pluginConfigs from "../imports/pluginConfig";
2
3
  let mockConfig = null;
3
4
  function getMockConfig() {
4
5
  return mockConfig;
@@ -33,12 +34,21 @@ function computeID(configFile, type, data) {
33
34
  }
34
35
  return id.slice(0, -2);
35
36
  }
37
+ let _configFile = null;
36
38
  function getCurrentConfig() {
37
39
  const mockConfig2 = getMockConfig();
38
40
  if (mockConfig2) {
39
41
  return mockConfig2;
40
42
  }
41
- return defaultConfigValues(config);
43
+ if (_configFile) {
44
+ return _configFile;
45
+ }
46
+ let configFile = defaultConfigValues(config);
47
+ for (const pluginConfig of pluginConfigs) {
48
+ configFile = pluginConfig(configFile);
49
+ }
50
+ _configFile = configFile;
51
+ return configFile;
42
52
  }
43
53
  export {
44
54
  computeID,
@@ -12,4 +12,4 @@ export declare function marshalInputs<T>({ artifact, input, config, rootType, }:
12
12
  }): {} | null | undefined;
13
13
  export declare function unmarshalSelection(config: ConfigFile, selection: SubscriptionSelection, data: any): {} | null | undefined;
14
14
  export declare function isScalar(config: ConfigFile, type: string): boolean;
15
- export declare function parseScalar(config: ConfigFile, type: string, value: string): string | number | boolean;
15
+ export declare function parseScalar(config: ConfigFile, type: string, value?: string): string | number | boolean | undefined;
@@ -118,6 +118,9 @@ function isScalar(config, type) {
118
118
  return ["String", "Boolean", "Float", "ID", "Int"].concat(Object.keys(config.scalars || {})).includes(type);
119
119
  }
120
120
  function parseScalar(config, type, value) {
121
+ if (typeof value === "undefined") {
122
+ return void 0;
123
+ }
121
124
  if (type === "Boolean") {
122
125
  return value === "true";
123
126
  }
@@ -128,10 +131,18 @@ function parseScalar(config, type, value) {
128
131
  return value;
129
132
  }
130
133
  if (type === "Int") {
131
- return parseInt(value, 10);
134
+ const result = parseInt(value, 10);
135
+ if (Number.isNaN(result)) {
136
+ return void 0;
137
+ }
138
+ return result;
132
139
  }
133
140
  if (type === "Float") {
134
- return parseFloat(value);
141
+ const result = parseFloat(value);
142
+ if (Number.isNaN(result)) {
143
+ return void 0;
144
+ }
145
+ return result;
135
146
  }
136
147
  if (config.scalars?.[type]?.marshal) {
137
148
  return config.scalars[type]?.marshal(value);