houdini 1.0.0-next.2 → 1.0.0-next.20

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 (195) hide show
  1. package/README.md +4 -1
  2. package/build/cmd-cjs/index.js +5366 -2772
  3. package/build/cmd-esm/index.js +5340 -2746
  4. package/build/codegen/generators/artifacts/index.d.ts +2 -2
  5. package/build/codegen/generators/artifacts/indexFile.d.ts +2 -2
  6. package/build/codegen/generators/artifacts/selection.d.ts +5 -5
  7. package/build/codegen/generators/artifacts/utils.d.ts +0 -1
  8. package/build/codegen/generators/indexFile/index.d.ts +2 -2
  9. package/build/codegen/generators/persistedQueries/index.d.ts +2 -2
  10. package/build/codegen/generators/runtime/graphqlFunction.d.ts +2 -2
  11. package/build/codegen/generators/runtime/index.d.ts +2 -2
  12. package/build/codegen/generators/runtime/runtimeConfig.d.ts +7 -0
  13. package/build/codegen/generators/typescript/documentTypes.d.ts +2 -0
  14. package/build/codegen/generators/typescript/imperativeTypeDef.d.ts +2 -0
  15. package/build/codegen/generators/typescript/index.d.ts +2 -2
  16. package/build/codegen/generators/typescript/typeReference.d.ts +4 -2
  17. package/build/codegen/generators/typescript/types.d.ts +0 -1
  18. package/build/codegen/index.d.ts +2 -2
  19. package/build/codegen/transforms/addID.d.ts +2 -2
  20. package/build/codegen/transforms/composeQueries.d.ts +4 -4
  21. package/build/codegen/transforms/fragmentVariables.d.ts +3 -2
  22. package/build/codegen/transforms/list.d.ts +2 -2
  23. package/build/codegen/transforms/paginate.d.ts +2 -2
  24. package/build/codegen/transforms/schema.d.ts +2 -2
  25. package/build/codegen/transforms/typename.d.ts +2 -2
  26. package/build/codegen/utils/flattenSelections.d.ts +1 -1
  27. package/build/codegen/validators/noIDAlias.d.ts +2 -2
  28. package/build/codegen/validators/plugins.d.ts +2 -2
  29. package/build/codegen/validators/typeCheck.d.ts +2 -2
  30. package/build/codegen/validators/uniqueNames.d.ts +2 -2
  31. package/build/codegen-cjs/index.js +4694 -2137
  32. package/build/codegen-esm/index.js +4682 -2125
  33. package/build/lib/config.d.ts +15 -96
  34. package/build/lib/deepMerge.d.ts +1 -0
  35. package/build/lib/graphql.d.ts +5 -2
  36. package/build/lib/index.d.ts +2 -0
  37. package/build/lib/path.d.ts +1 -1
  38. package/build/lib/pipeline.d.ts +1 -1
  39. package/build/lib/plugin.d.ts +2 -0
  40. package/build/lib/types.d.ts +257 -6
  41. package/build/lib/walk.d.ts +4 -1
  42. package/build/lib-cjs/index.js +4108 -928
  43. package/build/lib-esm/index.js +4078 -907
  44. package/build/runtime/cache/cache.d.ts +28 -11
  45. package/build/runtime/cache/lists.d.ts +1 -0
  46. package/build/runtime/cache/staleManager.d.ts +30 -0
  47. package/build/runtime/cache/storage.d.ts +23 -20
  48. package/build/runtime/cache/stuff.d.ts +0 -2
  49. package/build/runtime/cache/subscription.d.ts +2 -1
  50. package/build/runtime/client/documentStore.d.ts +20 -17
  51. package/build/runtime/client/index.d.ts +13 -11
  52. package/build/runtime/client/plugins/cache.d.ts +1 -1
  53. package/build/runtime/client/plugins/fetch.d.ts +1 -1
  54. package/build/runtime/client/plugins/fetchParams.d.ts +2 -2
  55. package/build/runtime/client/plugins/injectedPlugins.d.ts +2 -1
  56. package/build/runtime/client/plugins/mutation.d.ts +1 -1
  57. package/build/runtime/client/plugins/query.d.ts +1 -1
  58. package/build/runtime/client/plugins/subscription.d.ts +2 -3
  59. package/build/runtime/client/plugins/throwOnError.d.ts +1 -1
  60. package/build/runtime/client/utils/documentPlugins.d.ts +3 -3
  61. package/build/runtime/generated.d.ts +1 -0
  62. package/build/runtime/imports/pluginConfig.d.ts +3 -0
  63. package/build/runtime/index.d.ts +1 -1
  64. package/build/runtime/lib/config.d.ts +27 -24
  65. package/build/runtime/lib/flatten.d.ts +2 -0
  66. package/build/runtime/lib/index.d.ts +1 -0
  67. package/build/runtime/lib/key.d.ts +6 -0
  68. package/build/runtime/lib/scalars.d.ts +3 -3
  69. package/build/runtime/lib/types.d.ts +46 -46
  70. package/build/runtime/public/cache.d.ts +26 -6
  71. package/build/runtime/public/record.d.ts +26 -17
  72. package/build/runtime/public/tests/test.d.ts +52 -10
  73. package/build/runtime/public/types.d.ts +8 -0
  74. package/build/runtime-cjs/cache/cache.d.ts +28 -11
  75. package/build/runtime-cjs/cache/cache.js +97 -22
  76. package/build/runtime-cjs/cache/gc.js +9 -0
  77. package/build/runtime-cjs/cache/lists.d.ts +1 -0
  78. package/build/runtime-cjs/cache/lists.js +9 -6
  79. package/build/runtime-cjs/cache/staleManager.d.ts +30 -0
  80. package/build/runtime-cjs/cache/staleManager.js +95 -0
  81. package/build/runtime-cjs/cache/storage.d.ts +23 -20
  82. package/build/runtime-cjs/cache/storage.js +11 -13
  83. package/build/runtime-cjs/cache/stuff.d.ts +0 -2
  84. package/build/runtime-cjs/cache/stuff.js +2 -19
  85. package/build/runtime-cjs/cache/subscription.d.ts +2 -1
  86. package/build/runtime-cjs/cache/subscription.js +11 -7
  87. package/build/runtime-cjs/client/documentStore.d.ts +20 -17
  88. package/build/runtime-cjs/client/documentStore.js +12 -8
  89. package/build/runtime-cjs/client/index.d.ts +13 -11
  90. package/build/runtime-cjs/client/index.js +48 -19
  91. package/build/runtime-cjs/client/plugins/cache.d.ts +1 -1
  92. package/build/runtime-cjs/client/plugins/cache.js +10 -8
  93. package/build/runtime-cjs/client/plugins/fetch.d.ts +1 -1
  94. package/build/runtime-cjs/client/plugins/fetch.js +9 -8
  95. package/build/runtime-cjs/client/plugins/fetchParams.d.ts +2 -2
  96. package/build/runtime-cjs/client/plugins/fetchParams.js +9 -4
  97. package/build/runtime-cjs/client/plugins/injectedPlugins.d.ts +2 -1
  98. package/build/runtime-cjs/client/plugins/mutation.d.ts +1 -1
  99. package/build/runtime-cjs/client/plugins/mutation.js +3 -3
  100. package/build/runtime-cjs/client/plugins/query.d.ts +1 -1
  101. package/build/runtime-cjs/client/plugins/query.js +4 -4
  102. package/build/runtime-cjs/client/plugins/subscription.d.ts +2 -3
  103. package/build/runtime-cjs/client/plugins/subscription.js +5 -3
  104. package/build/runtime-cjs/client/plugins/throwOnError.d.ts +1 -1
  105. package/build/runtime-cjs/client/plugins/throwOnError.js +3 -3
  106. package/build/runtime-cjs/client/utils/documentPlugins.d.ts +3 -3
  107. package/build/runtime-cjs/generated.d.ts +1 -0
  108. package/build/runtime-cjs/imports/pluginConfig.d.ts +3 -0
  109. package/build/runtime-cjs/imports/pluginConfig.js +27 -0
  110. package/build/runtime-cjs/index.d.ts +1 -1
  111. package/build/runtime-cjs/lib/config.d.ts +27 -24
  112. package/build/runtime-cjs/lib/config.js +11 -1
  113. package/build/runtime-cjs/lib/flatten.d.ts +2 -0
  114. package/build/runtime-cjs/lib/flatten.js +41 -0
  115. package/build/runtime-cjs/lib/index.d.ts +1 -0
  116. package/build/runtime-cjs/lib/index.js +1 -0
  117. package/build/runtime-cjs/lib/key.d.ts +6 -0
  118. package/build/runtime-cjs/lib/key.js +41 -0
  119. package/build/runtime-cjs/lib/scalars.d.ts +3 -3
  120. package/build/runtime-cjs/lib/scalars.js +13 -2
  121. package/build/runtime-cjs/lib/types.d.ts +46 -46
  122. package/build/runtime-cjs/lib/types.js +26 -30
  123. package/build/runtime-cjs/public/cache.d.ts +26 -6
  124. package/build/runtime-cjs/public/cache.js +32 -32
  125. package/build/runtime-cjs/public/list.js +6 -28
  126. package/build/runtime-cjs/public/record.d.ts +26 -17
  127. package/build/runtime-cjs/public/record.js +27 -187
  128. package/build/runtime-cjs/public/tests/test.d.ts +52 -10
  129. package/build/runtime-cjs/public/tests/test.js +27 -2
  130. package/build/runtime-cjs/public/types.d.ts +8 -0
  131. package/build/runtime-esm/cache/cache.d.ts +28 -11
  132. package/build/runtime-esm/cache/cache.js +99 -24
  133. package/build/runtime-esm/cache/gc.js +9 -0
  134. package/build/runtime-esm/cache/lists.d.ts +1 -0
  135. package/build/runtime-esm/cache/lists.js +9 -6
  136. package/build/runtime-esm/cache/staleManager.d.ts +30 -0
  137. package/build/runtime-esm/cache/staleManager.js +71 -0
  138. package/build/runtime-esm/cache/storage.d.ts +23 -20
  139. package/build/runtime-esm/cache/storage.js +11 -13
  140. package/build/runtime-esm/cache/stuff.d.ts +0 -2
  141. package/build/runtime-esm/cache/stuff.js +1 -17
  142. package/build/runtime-esm/cache/subscription.d.ts +2 -1
  143. package/build/runtime-esm/cache/subscription.js +12 -8
  144. package/build/runtime-esm/client/documentStore.d.ts +20 -17
  145. package/build/runtime-esm/client/documentStore.js +13 -9
  146. package/build/runtime-esm/client/index.d.ts +13 -11
  147. package/build/runtime-esm/client/index.js +49 -21
  148. package/build/runtime-esm/client/plugins/cache.d.ts +1 -1
  149. package/build/runtime-esm/client/plugins/cache.js +9 -7
  150. package/build/runtime-esm/client/plugins/fetch.d.ts +1 -1
  151. package/build/runtime-esm/client/plugins/fetch.js +8 -7
  152. package/build/runtime-esm/client/plugins/fetchParams.d.ts +2 -2
  153. package/build/runtime-esm/client/plugins/fetchParams.js +8 -3
  154. package/build/runtime-esm/client/plugins/injectedPlugins.d.ts +2 -1
  155. package/build/runtime-esm/client/plugins/mutation.d.ts +1 -1
  156. package/build/runtime-esm/client/plugins/mutation.js +2 -2
  157. package/build/runtime-esm/client/plugins/query.d.ts +1 -1
  158. package/build/runtime-esm/client/plugins/query.js +3 -3
  159. package/build/runtime-esm/client/plugins/subscription.d.ts +2 -3
  160. package/build/runtime-esm/client/plugins/subscription.js +4 -2
  161. package/build/runtime-esm/client/plugins/throwOnError.d.ts +1 -1
  162. package/build/runtime-esm/client/plugins/throwOnError.js +2 -2
  163. package/build/runtime-esm/client/utils/documentPlugins.d.ts +3 -3
  164. package/build/runtime-esm/generated.d.ts +1 -0
  165. package/build/runtime-esm/imports/pluginConfig.d.ts +3 -0
  166. package/build/runtime-esm/imports/pluginConfig.js +5 -0
  167. package/build/runtime-esm/index.d.ts +1 -1
  168. package/build/runtime-esm/lib/config.d.ts +27 -24
  169. package/build/runtime-esm/lib/config.js +11 -1
  170. package/build/runtime-esm/lib/flatten.d.ts +2 -0
  171. package/build/runtime-esm/lib/flatten.js +17 -0
  172. package/build/runtime-esm/lib/index.d.ts +1 -0
  173. package/build/runtime-esm/lib/index.js +1 -0
  174. package/build/runtime-esm/lib/key.d.ts +6 -0
  175. package/build/runtime-esm/lib/key.js +17 -0
  176. package/build/runtime-esm/lib/scalars.d.ts +3 -3
  177. package/build/runtime-esm/lib/scalars.js +13 -2
  178. package/build/runtime-esm/lib/types.d.ts +46 -46
  179. package/build/runtime-esm/lib/types.js +26 -30
  180. package/build/runtime-esm/public/cache.d.ts +26 -6
  181. package/build/runtime-esm/public/cache.js +31 -30
  182. package/build/runtime-esm/public/list.js +6 -28
  183. package/build/runtime-esm/public/record.d.ts +26 -17
  184. package/build/runtime-esm/public/record.js +26 -183
  185. package/build/runtime-esm/public/tests/test.d.ts +52 -10
  186. package/build/runtime-esm/public/tests/test.js +26 -1
  187. package/build/runtime-esm/public/types.d.ts +8 -0
  188. package/build/test/index.d.ts +3 -3
  189. package/build/test-cjs/index.js +5007 -2465
  190. package/build/test-esm/index.js +4995 -2453
  191. package/build/vite/houdini.d.ts +2 -0
  192. package/build/vite-cjs/index.js +5344 -2744
  193. package/build/vite-esm/index.js +5319 -2719
  194. package/package.json +6 -5
  195. package/build/codegen/generators/typescript/imperativeCache.d.ts +0 -2
@@ -1,9 +1,9 @@
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;
8
- artifact: DocumentArtifact;
8
+ document: DocumentArtifact;
9
9
  };
@@ -1,9 +1,14 @@
1
- const fetchParamsPlugin = (fn = () => ({})) => () => ({
1
+ const fetchParams = (fn = () => ({})) => () => ({
2
2
  beforeNetwork(ctx, { next, marshalVariables }) {
3
3
  next({
4
4
  ...ctx,
5
5
  fetchParams: fn({
6
- ...ctx,
6
+ config: ctx.config,
7
+ policy: ctx.policy,
8
+ metadata: ctx.metadata,
9
+ session: ctx.session,
10
+ stuff: ctx.stuff,
11
+ document: ctx.artifact,
7
12
  variables: marshalVariables(ctx),
8
13
  text: ctx.artifact.raw,
9
14
  hash: ctx.artifact.hash
@@ -12,5 +17,5 @@ const fetchParamsPlugin = (fn = () => ({})) => () => ({
12
17
  }
13
18
  });
14
19
  export {
15
- fetchParamsPlugin
20
+ fetchParams
16
21
  };
@@ -1,3 +1,4 @@
1
+ import type { NestedList } from '../../lib/types';
1
2
  import type { ClientPlugin } from '../documentStore';
2
- declare const plugins: ClientPlugin[];
3
+ declare const plugins: NestedList<ClientPlugin>;
3
4
  export default plugins;
@@ -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 = "";
@@ -25,12 +25,12 @@ const queryPlugin = documentPlugin(ArtifactKind.Query, function() {
25
25
  selection: ctx.artifact.selection,
26
26
  variables: () => lastVariables,
27
27
  set: (newValue) => {
28
- console.log("setting from cache update");
29
28
  resolve(ctx, {
30
29
  data: newValue,
31
30
  errors: null,
32
31
  fetching: false,
33
32
  partial: false,
33
+ stale: false,
34
34
  source: DataSource.Cache,
35
35
  variables: ctx.variables ?? null
36
36
  });
@@ -49,5 +49,5 @@ const queryPlugin = documentPlugin(ArtifactKind.Query, function() {
49
49
  };
50
50
  });
51
51
  export {
52
- queryPlugin
52
+ query
53
53
  };
@@ -1,13 +1,12 @@
1
- import type { GraphQLObject } from '../../lib/types';
2
1
  import type { ClientPluginContext } from '../documentStore';
3
- export declare function subscriptionPlugin(factory: SubscriptionHandler): import("../documentStore").ClientPlugin;
2
+ export declare function subscription(factory: SubscriptionHandler): import("../documentStore").ClientPlugin;
4
3
  export type SubscriptionHandler = (ctx: ClientPluginContext) => {
5
4
  subscribe: (payload: {
6
5
  query: string;
7
6
  variables?: {};
8
7
  }, handlers: {
9
8
  next: (payload: {
10
- data?: GraphQLObject;
9
+ data?: {} | null;
11
10
  errors?: readonly {
12
11
  message: string;
13
12
  }[];
@@ -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;
@@ -43,6 +43,7 @@ function subscriptionPlugin(factory) {
43
43
  errors: [...errors ?? []],
44
44
  fetching: false,
45
45
  partial: true,
46
+ stale: false,
46
47
  source: DataSource.Network,
47
48
  variables: ctx.variables ?? null
48
49
  });
@@ -51,6 +52,7 @@ function subscriptionPlugin(factory) {
51
52
  clearSubscription?.();
52
53
  resolve(ctx, {
53
54
  partial: true,
55
+ stale: false,
54
56
  source: DataSource.Network,
55
57
  data: null,
56
58
  errors: [data],
@@ -70,5 +72,5 @@ function subscriptionPlugin(factory) {
70
72
  });
71
73
  }
72
74
  export {
73
- subscriptionPlugin
75
+ subscription
74
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';
2
- import type { ClientPlugin } from '../documentStore';
3
- export declare const documentPlugin: (kind: ArtifactKind, source: ClientPlugin) => ClientPlugin;
1
+ import type { ArtifactKinds } from '../../lib/types';
2
+ import type { ClientPlugin, ClientHooks } from '../documentStore';
3
+ export declare const documentPlugin: (kind: ArtifactKinds, source: () => ClientHooks) => ClientPlugin;
@@ -1,4 +1,5 @@
1
1
  export type CacheTypeDef = {
2
2
  types: {};
3
3
  lists: {};
4
+ queries: [];
4
5
  };
@@ -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
+ };
@@ -3,6 +3,6 @@ import type { CacheTypeDef } from './generated';
3
3
  import { Cache } from './public';
4
4
  export * from './client';
5
5
  export * from './lib';
6
- export declare function graphql(str: string | TemplateStringsArray): any;
6
+ export declare function graphql<_Payload>(str: TemplateStringsArray): _Payload;
7
7
  export declare const cache: Cache<CacheTypeDef>;
8
8
  export declare function getCache(): InternalCache;
@@ -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;
@@ -31,10 +31,6 @@ export type ConfigFile = {
31
31
  * FYI: `schemaPath` or `schema` should be defined
32
32
  */
33
33
  schema?: string | GraphQLSchema;
34
- /**
35
- * A url to use to pull the schema. For more information: https://www.houdinigraphql.com/api/cli#generate
36
- */
37
- apiUrl?: string | ((env: Record<string, string | undefined>) => string);
38
34
  /**
39
35
  * An object describing custom scalars for your project. For more information: https://www.houdinigraphql.com/api/config#custom-scalars
40
36
  */
@@ -43,11 +39,6 @@ export type ConfigFile = {
43
39
  * A path that the generator will use to write schema.graphql and documents.gql files containing all of the internal fragment and directive definitions used in the project.
44
40
  */
45
41
  definitionsPath?: string;
46
- /**
47
- * One of "kit" or "svelte". Used to tell the preprocessor what kind of loading paradigm to generate for you. (default: `kit`)
48
- * @deprecated please follow the steps here: http://www.houdinigraphql.com/guides/release-notes#0170
49
- */
50
- framework?: 'kit' | 'svelte';
51
42
  /**
52
43
  * One of "esm" or "commonjs". Tells the artifact generator what kind of modules to create. (default: `esm`)
53
44
  */
@@ -59,11 +50,15 @@ export type ConfigFile = {
59
50
  /**
60
51
  * The default cache policy to use for queries. For more information: https://www.houdinigraphql.com/guides/caching-data
61
52
  */
62
- defaultCachePolicy?: CachePolicy;
53
+ defaultCachePolicy?: CachePolicies;
63
54
  /**
64
55
  * Specifies whether or not the cache should always use partial data. For more information: https://www.houdinigraphql.com/guides/caching-data#partial-data
65
56
  */
66
57
  defaultPartial?: boolean;
58
+ /**
59
+ * Specifies after how long a data goes stale in miliseconds. (default: `undefined`)
60
+ */
61
+ defaultLifetime?: number;
67
62
  /**
68
63
  * Specifies whether mutations should append or prepend list. For more information: https://www.houdinigraphql.com/api/graphql (default: `append`)
69
64
  */
@@ -90,20 +85,9 @@ export type ConfigFile = {
90
85
  */
91
86
  defaultFragmentMasking?: 'enable' | 'disable';
92
87
  /**
93
- * Configures the houdini plugin's schema polling behavior. By default, houdini will poll your APIs
94
- * during development in order to keep it's definition of your schema up to date. The schemaPollingInterval
95
- * config value sets the amount of time between each request in milliseconds (default 2 seconds).
96
- * To limit the schema introspection to just on the start of the server, set schemaPollingInterval to 0.
97
- * To disable the schema introspection, set schemaPollingInterval to null.
98
- */
99
- schemaPollInterval?: number | null;
100
- /**
101
- * An object containing the environment variables you want passed onto the api when polling for a new schema.
102
- * The keys dictate the header names. If the value is a string, the corresponding environment variable will be used
103
- * directly. If the value is a function, the current environment will be passed to your function so you can perform any
104
- * logic you need
88
+ * Configure the dev environment to watch a remote schema for changes
105
89
  */
106
- schemaPollHeaders?: Record<string, string | ((env: Record<string, string | undefined>) => string)> | ((env: Record<string, string | undefined>) => Record<string, string>);
90
+ watchSchema?: WatchSchemaConfig;
107
91
  /**
108
92
  * An object describing the plugins enabled for the project
109
93
  */
@@ -133,6 +117,25 @@ export type TypeConfig = {
133
117
  };
134
118
  };
135
119
  };
120
+ export type WatchSchemaConfig = {
121
+ /**
122
+ * A url to use to pull the schema. For more information: https://www.houdinigraphql.com/api/cli#generate
123
+ */
124
+ url: string | ((env: Record<string, string | undefined>) => string);
125
+ /**
126
+ * sets the amount of time between each request in milliseconds (default 2 seconds).
127
+ * To limit the schema introspection to just on the start of the server, set interval to 0.
128
+ * To disable the schema introspection, set interval to null.
129
+ */
130
+ interval?: number | null;
131
+ /**
132
+ * An object containing the environment variables you want passed onto the api when polling for a new schema.
133
+ * The keys dictate the header names. If the value is a string, the corresponding environment variable will be used
134
+ * directly. If the value is a function, the current environment will be passed to your function so you can perform any
135
+ * logic you need
136
+ */
137
+ headers?: Record<string, string | ((env: Record<string, string | undefined>) => string)> | ((env: Record<string, string | undefined>) => Record<string, string>);
138
+ };
136
139
  export type ScalarSpec = {
137
140
  type: string;
138
141
  marshal?: (val: any) => any;
@@ -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,
@@ -0,0 +1,2 @@
1
+ import type { NestedList } from './types';
2
+ export declare function flatten<T>(source?: NestedList<T>): T[];
@@ -0,0 +1,17 @@
1
+ function flatten(source) {
2
+ if (!source) {
3
+ return [];
4
+ }
5
+ return source.reduce((acc, element) => {
6
+ if (!element) {
7
+ return acc;
8
+ }
9
+ if (Array.isArray(element)) {
10
+ return acc.concat(flatten(element));
11
+ }
12
+ return acc.concat(element);
13
+ }, []);
14
+ }
15
+ export {
16
+ flatten
17
+ };
@@ -5,3 +5,4 @@ export * from './log';
5
5
  export * from './scalars';
6
6
  export * from './types';
7
7
  export * from './store';
8
+ export * from './key';
@@ -5,3 +5,4 @@ export * from "./log";
5
5
  export * from "./scalars";
6
6
  export * from "./types";
7
7
  export * from "./store";
8
+ export * from "./key";
@@ -0,0 +1,6 @@
1
+ export declare const computeKey: ({ field, args }: {
2
+ field: string;
3
+ args?: {
4
+ [key: string]: any;
5
+ } | undefined;
6
+ }) => string;
@@ -0,0 +1,17 @@
1
+ const computeKey = ({ field, args }) => {
2
+ const keys = Object.keys(args ?? {});
3
+ keys.sort();
4
+ return args && keys.length > 0 ? `${field}(${keys.map((key) => `${key}: ${stringifyObjectWithNoQuotesOnKeys(args[key])}`).join(", ")})` : field;
5
+ };
6
+ const stringifyObjectWithNoQuotesOnKeys = (obj_from_json) => {
7
+ if (Array.isArray(obj_from_json)) {
8
+ return `[${obj_from_json.map((obj) => `${stringifyObjectWithNoQuotesOnKeys(obj)}`).join(", ")}]`;
9
+ }
10
+ if (typeof obj_from_json !== "object" || obj_from_json instanceof Date || obj_from_json === null) {
11
+ return JSON.stringify(obj_from_json).replace(/"([^"]+)":/g, "$1: ");
12
+ }
13
+ return `{${Object.keys(obj_from_json).map((key) => `${key}: ${stringifyObjectWithNoQuotesOnKeys(obj_from_json[key])}`).join(", ")}}`;
14
+ };
15
+ export {
16
+ computeKey
17
+ };
@@ -1,15 +1,15 @@
1
1
  import type { ConfigFile } from './config';
2
- import type { MutationArtifact, QueryArtifact, SubscriptionArtifact, SubscriptionSelection } from './types';
2
+ import type { FragmentArtifact, MutationArtifact, QueryArtifact, SubscriptionArtifact, SubscriptionSelection } from './types';
3
3
  export declare function marshalSelection({ selection, data, }: {
4
4
  selection: SubscriptionSelection;
5
5
  data: any;
6
6
  }): Promise<{} | null | undefined>;
7
7
  export declare function marshalInputs<T>({ artifact, input, config, rootType, }: {
8
- artifact: QueryArtifact | MutationArtifact | SubscriptionArtifact;
8
+ artifact: QueryArtifact | MutationArtifact | SubscriptionArtifact | FragmentArtifact;
9
9
  input: unknown;
10
10
  rootType?: string;
11
11
  config: ConfigFile;
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);
@@ -1,9 +1,11 @@
1
- export declare enum CachePolicy {
2
- CacheOrNetwork = "CacheOrNetwork",
3
- CacheOnly = "CacheOnly",
4
- NetworkOnly = "NetworkOnly",
5
- CacheAndNetwork = "CacheAndNetwork"
6
- }
1
+ export declare const CachePolicy: {
2
+ readonly CacheOrNetwork: "CacheOrNetwork";
3
+ readonly CacheOnly: "CacheOnly";
4
+ readonly NetworkOnly: "NetworkOnly";
5
+ readonly CacheAndNetwork: "CacheAndNetwork";
6
+ };
7
+ type ValuesOf<Target> = Target[keyof Target];
8
+ export type CachePolicies = ValuesOf<typeof CachePolicy>;
7
9
  declare global {
8
10
  namespace App {
9
11
  interface Session {
@@ -29,49 +31,44 @@ export type Operation<_Result, _Input> = {
29
31
  };
30
32
  export type Maybe<T> = T | null | undefined;
31
33
  export type DocumentArtifact = FragmentArtifact | QueryArtifact | MutationArtifact | SubscriptionArtifact;
32
- export declare enum ArtifactKind {
33
- Query = "HoudiniQuery",
34
- Subscription = "HoudiniSubscription",
35
- Mutation = "HoudiniMutation",
36
- Fragment = "HoudiniFragment"
37
- }
38
- export declare const CompiledFragmentKind = ArtifactKind.Fragment;
39
- export declare const CompiledMutationKind = ArtifactKind.Mutation;
40
- export declare const CompiledQueryKind = ArtifactKind.Query;
41
- export declare const CompiledSubscriptionKind = ArtifactKind.Subscription;
42
- export type CompiledDocumentKind = ArtifactKind;
43
- export type QueryArtifact = BaseCompiledDocument & {
44
- kind: ArtifactKind.Query;
45
- policy?: CachePolicy;
34
+ export declare const ArtifactKind: {
35
+ readonly Query: "HoudiniQuery";
36
+ readonly Subscription: "HoudiniSubscription";
37
+ readonly Mutation: "HoudiniMutation";
38
+ readonly Fragment: "HoudiniFragment";
39
+ };
40
+ export type ArtifactKinds = ValuesOf<typeof ArtifactKind>;
41
+ export declare const CompiledFragmentKind: "HoudiniFragment";
42
+ export declare const CompiledMutationKind: "HoudiniMutation";
43
+ export declare const CompiledQueryKind: "HoudiniQuery";
44
+ export declare const CompiledSubscriptionKind: "HoudiniSubscription";
45
+ export type CompiledDocumentKind = ArtifactKinds;
46
+ export type QueryArtifact = BaseCompiledDocument<'HoudiniQuery'> & {
47
+ policy?: CachePolicies;
46
48
  partial?: boolean;
47
49
  };
48
- export type MutationArtifact = BaseCompiledDocument & {
49
- kind: ArtifactKind.Mutation;
50
- };
51
- export type FragmentArtifact = BaseCompiledDocument & {
52
- kind: ArtifactKind.Fragment;
53
- };
54
- export type SubscriptionArtifact = BaseCompiledDocument & {
55
- kind: ArtifactKind.Subscription;
50
+ export type MutationArtifact = BaseCompiledDocument<'HoudiniMutation'>;
51
+ export type FragmentArtifact = BaseCompiledDocument<'HoudiniFragment'>;
52
+ export type SubscriptionArtifact = BaseCompiledDocument<'HoudiniSubscription'>;
53
+ export declare const RefetchUpdateMode: {
54
+ readonly append: "append";
55
+ readonly prepend: "prepend";
56
+ readonly replace: "replace";
56
57
  };
57
- export declare enum RefetchUpdateMode {
58
- append = "append",
59
- prepend = "prepend",
60
- replace = "replace"
61
- }
58
+ export type RefetchUpdateModes = ValuesOf<typeof RefetchUpdateMode>;
62
59
  export type InputObject = {
63
60
  fields: Record<string, string>;
64
61
  types: Record<string, Record<string, string>>;
65
62
  };
66
- export type BaseCompiledDocument = {
63
+ export type BaseCompiledDocument<_Kind extends ArtifactKinds> = {
67
64
  name: string;
65
+ kind: _Kind;
68
66
  raw: string;
69
67
  hash: string;
70
68
  selection: SubscriptionSelection;
71
69
  rootType: string;
72
70
  input?: InputObject;
73
71
  refetch?: {
74
- update: RefetchUpdateMode;
75
72
  path: string[];
76
73
  method: 'cursor' | 'offset';
77
74
  pageSize: number;
@@ -79,9 +76,9 @@ export type BaseCompiledDocument = {
79
76
  embedded: boolean;
80
77
  targetType: string;
81
78
  paginated: boolean;
82
- direction?: 'forward' | 'backwards';
79
+ direction: 'forward' | 'backward' | 'both';
83
80
  };
84
- pluginsData?: Record<string, any>;
81
+ pluginData?: Record<string, any>;
85
82
  };
86
83
  export type HoudiniFetchContext = {
87
84
  variables: () => {};
@@ -93,20 +90,21 @@ export type ListWhen = {
93
90
  must?: Filter;
94
91
  must_not?: Filter;
95
92
  };
96
- export declare enum DataSource {
93
+ export declare const DataSource: {
97
94
  /**
98
95
  * from the browser cache
99
96
  */
100
- Cache = "cache",
97
+ readonly Cache: "cache";
101
98
  /**
102
99
  * from a browser side `fetch`
103
100
  */
104
- Network = "network",
101
+ readonly Network: "network";
105
102
  /**
106
103
  * from a server side `fetch`
107
104
  */
108
- Ssr = "ssr"
109
- }
105
+ readonly Ssr: "ssr";
106
+ };
107
+ export type DataSources = ValuesOf<typeof DataSource>;
110
108
  export type MutationOperation = {
111
109
  action: 'insert' | 'remove' | 'delete' | 'toggle';
112
110
  list?: string;
@@ -135,7 +133,7 @@ export type SubscriptionSelection = {
135
133
  connection: boolean;
136
134
  type: string;
137
135
  };
138
- update?: RefetchUpdateMode;
136
+ updates?: string[];
139
137
  filters?: {
140
138
  [key: string]: {
141
139
  kind: 'Boolean' | 'String' | 'Float' | 'Int' | 'Variable';
@@ -164,8 +162,7 @@ export type SubscriptionSpec = {
164
162
  };
165
163
  export type FetchQueryResult<_Data> = {
166
164
  result: RequestPayload<_Data | null>;
167
- source: DataSource | null;
168
- partial: boolean;
165
+ source: DataSources | null;
169
166
  };
170
167
  export type QueryResult<_Data = GraphQLObject, _Input = Record<string, any>> = {
171
168
  data: _Data | null;
@@ -174,7 +171,8 @@ export type QueryResult<_Data = GraphQLObject, _Input = Record<string, any>> = {
174
171
  }[] | null;
175
172
  fetching: boolean;
176
173
  partial: boolean;
177
- source: DataSource | null;
174
+ stale: boolean;
175
+ source: DataSources | null;
178
176
  variables: _Input | null;
179
177
  };
180
178
  export type RequestPayload<GraphQLObject = any> = {
@@ -183,4 +181,6 @@ export type RequestPayload<GraphQLObject = any> = {
183
181
  message: string;
184
182
  }[] | null;
185
183
  };
184
+ export type NestedList<_Result = string> = (_Result | null | NestedList<_Result>)[];
185
+ export type ValueOf<Parent> = Parent[keyof Parent];
186
186
  export {};