houdini 1.2.0-react.1 → 1.2.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 (79) hide show
  1. package/README.md +1 -1
  2. package/build/cmd-cjs/index.js +2213 -1533
  3. package/build/cmd-esm/index.js +2213 -1533
  4. package/build/codegen/generators/artifacts/selection.d.ts +2 -1
  5. package/build/codegen/generators/typescript/inlineType.d.ts +5 -2
  6. package/build/codegen/generators/typescript/loadingState.d.ts +8 -0
  7. package/build/codegen/transforms/fragmentVariables.d.ts +0 -11
  8. package/build/codegen-cjs/index.js +2143 -1487
  9. package/build/codegen-esm/index.js +2143 -1487
  10. package/build/lib/config.d.ts +5 -0
  11. package/build/lib/graphql.d.ts +5 -1
  12. package/build/lib/parse.d.ts +10 -1
  13. package/build/lib-cjs/index.js +702 -578
  14. package/build/lib-esm/index.js +699 -578
  15. package/build/runtime/cache/cache.d.ts +9 -8
  16. package/build/runtime/cache/stuff.d.ts +1 -4
  17. package/build/runtime/client/documentStore.d.ts +3 -3
  18. package/build/runtime/client/index.d.ts +8 -7
  19. package/build/runtime/client/plugins/cache.d.ts +1 -1
  20. package/build/runtime/client/plugins/fetch.d.ts +1 -0
  21. package/build/runtime/client/plugins/subscription.d.ts +1 -0
  22. package/build/runtime/client/plugins/throwOnError.d.ts +2 -1
  23. package/build/runtime/lib/pagination.d.ts +4 -6
  24. package/build/runtime/lib/selection.d.ts +1 -1
  25. package/build/runtime/lib/types.d.ts +37 -4
  26. package/build/runtime-cjs/cache/cache.d.ts +9 -8
  27. package/build/runtime-cjs/cache/cache.js +108 -43
  28. package/build/runtime-cjs/cache/stuff.d.ts +1 -4
  29. package/build/runtime-cjs/cache/stuff.js +2 -2
  30. package/build/runtime-cjs/cache/subscription.js +5 -5
  31. package/build/runtime-cjs/client/documentStore.d.ts +3 -3
  32. package/build/runtime-cjs/client/documentStore.js +10 -2
  33. package/build/runtime-cjs/client/index.d.ts +8 -7
  34. package/build/runtime-cjs/client/index.js +12 -4
  35. package/build/runtime-cjs/client/plugins/cache.d.ts +1 -1
  36. package/build/runtime-cjs/client/plugins/cache.js +10 -2
  37. package/build/runtime-cjs/client/plugins/fetch.d.ts +1 -0
  38. package/build/runtime-cjs/client/plugins/fetch.js +3 -2
  39. package/build/runtime-cjs/client/plugins/subscription.d.ts +1 -0
  40. package/build/runtime-cjs/client/plugins/subscription.js +1 -0
  41. package/build/runtime-cjs/client/plugins/throwOnError.d.ts +2 -1
  42. package/build/runtime-cjs/lib/config.js +2 -1
  43. package/build/runtime-cjs/lib/pagination.d.ts +4 -6
  44. package/build/runtime-cjs/lib/pagination.js +0 -12
  45. package/build/runtime-cjs/lib/scalars.js +1 -1
  46. package/build/runtime-cjs/lib/selection.d.ts +1 -1
  47. package/build/runtime-cjs/lib/selection.js +28 -1
  48. package/build/runtime-cjs/lib/types.d.ts +37 -4
  49. package/build/runtime-cjs/lib/types.js +3 -0
  50. package/build/runtime-esm/cache/cache.d.ts +9 -8
  51. package/build/runtime-esm/cache/cache.js +109 -44
  52. package/build/runtime-esm/cache/stuff.d.ts +1 -4
  53. package/build/runtime-esm/cache/stuff.js +2 -2
  54. package/build/runtime-esm/cache/subscription.js +5 -5
  55. package/build/runtime-esm/client/documentStore.d.ts +3 -3
  56. package/build/runtime-esm/client/documentStore.js +10 -2
  57. package/build/runtime-esm/client/index.d.ts +8 -7
  58. package/build/runtime-esm/client/index.js +15 -7
  59. package/build/runtime-esm/client/plugins/cache.d.ts +1 -1
  60. package/build/runtime-esm/client/plugins/cache.js +10 -2
  61. package/build/runtime-esm/client/plugins/fetch.d.ts +1 -0
  62. package/build/runtime-esm/client/plugins/fetch.js +3 -2
  63. package/build/runtime-esm/client/plugins/subscription.d.ts +1 -0
  64. package/build/runtime-esm/client/plugins/subscription.js +1 -0
  65. package/build/runtime-esm/client/plugins/throwOnError.d.ts +2 -1
  66. package/build/runtime-esm/lib/config.js +2 -1
  67. package/build/runtime-esm/lib/pagination.d.ts +4 -6
  68. package/build/runtime-esm/lib/pagination.js +0 -12
  69. package/build/runtime-esm/lib/scalars.js +1 -1
  70. package/build/runtime-esm/lib/selection.d.ts +1 -1
  71. package/build/runtime-esm/lib/selection.js +28 -1
  72. package/build/runtime-esm/lib/types.d.ts +37 -4
  73. package/build/runtime-esm/lib/types.js +2 -0
  74. package/build/test/index.d.ts +15 -0
  75. package/build/test-cjs/index.js +2174 -1490
  76. package/build/test-esm/index.js +2174 -1490
  77. package/build/vite-cjs/index.js +2243 -1561
  78. package/build/vite-esm/index.js +2243 -1561
  79. package/package.json +7 -1
@@ -1,2 +1,2 @@
1
1
  import type { SubscriptionSelection } from './types';
2
- export declare function getFieldsForType(selection: SubscriptionSelection, __typename: string | undefined | null): Required<SubscriptionSelection>['fields'];
2
+ export declare function getFieldsForType(selection: SubscriptionSelection, __typename: string | undefined | null, loading: boolean): Required<SubscriptionSelection>['fields'];
@@ -1,4 +1,12 @@
1
- function getFieldsForType(selection, __typename) {
1
+ function getFieldsForType(selection, __typename, loading) {
2
+ if (loading) {
3
+ if (selection.loadingTypes && selection.loadingTypes.length > 0) {
4
+ return deepMerge(
5
+ ...selection.loadingTypes.map((type) => selection.abstractFields?.fields[type])
6
+ );
7
+ }
8
+ return selection.fields ?? {};
9
+ }
2
10
  let targetSelection = selection.fields || {};
3
11
  if (selection.abstractFields && __typename) {
4
12
  const mappedType = selection.abstractFields.typeMap[__typename];
@@ -10,6 +18,25 @@ function getFieldsForType(selection, __typename) {
10
18
  }
11
19
  return targetSelection;
12
20
  }
21
+ function deepMerge(...objects) {
22
+ const mergedObj = {};
23
+ for (let obj of objects) {
24
+ if (!obj) {
25
+ continue;
26
+ }
27
+ for (let prop in obj) {
28
+ if (prop in obj) {
29
+ const val = obj[prop];
30
+ if (typeof val === "object" && val !== null && !Array.isArray(val)) {
31
+ mergedObj[prop] = deepMerge(mergedObj[prop] || {}, val);
32
+ } else {
33
+ mergedObj[prop] = val;
34
+ }
35
+ }
36
+ }
37
+ }
38
+ return mergedObj;
39
+ }
13
40
  export {
14
41
  getFieldsForType
15
42
  };
@@ -53,9 +53,12 @@ export type CompiledDocumentKind = ArtifactKinds;
53
53
  export type QueryArtifact = BaseCompiledDocument<'HoudiniQuery'> & {
54
54
  policy?: CachePolicies;
55
55
  partial?: boolean;
56
+ enableLoadingState?: 'global' | 'local';
56
57
  };
57
58
  export type MutationArtifact = BaseCompiledDocument<'HoudiniMutation'>;
58
- export type FragmentArtifact = BaseCompiledDocument<'HoudiniFragment'>;
59
+ export type FragmentArtifact = BaseCompiledDocument<'HoudiniFragment'> & {
60
+ enableLoadingState?: 'global' | 'local';
61
+ };
59
62
  export type SubscriptionArtifact = BaseCompiledDocument<'HoudiniSubscription'>;
60
63
  export declare const RefetchUpdateMode: {
61
64
  readonly append: "append";
@@ -129,12 +132,34 @@ export type GraphQLObject = {
129
132
  [key: string]: GraphQLValue;
130
133
  };
131
134
  export type GraphQLValue = number | string | boolean | null | GraphQLObject | GraphQLValue[] | undefined;
135
+ export type GraphQLVariables = {
136
+ [key: string]: any;
137
+ } | null;
138
+ export type LoadingSpec = {
139
+ kind: 'continue';
140
+ list?: {
141
+ depth: number;
142
+ count: number;
143
+ };
144
+ } | {
145
+ kind: 'value';
146
+ value?: any;
147
+ list?: {
148
+ depth: number;
149
+ count: number;
150
+ };
151
+ };
132
152
  export type SubscriptionSelection = {
133
- fragments?: Record<string, ValueMap>;
153
+ loadingTypes?: string[];
154
+ fragments?: Record<string, {
155
+ arguments: ValueMap;
156
+ loading?: boolean;
157
+ }>;
134
158
  fields?: {
135
159
  [fieldName: string]: {
136
160
  type: string;
137
161
  nullable?: boolean;
162
+ required?: boolean;
138
163
  keyRaw: string;
139
164
  operations?: MutationOperation[];
140
165
  list?: {
@@ -142,6 +167,11 @@ export type SubscriptionSelection = {
142
167
  connection: boolean;
143
168
  type: string;
144
169
  };
170
+ loading?: LoadingSpec;
171
+ directives?: {
172
+ name: string;
173
+ arguments: ValueMap;
174
+ }[];
145
175
  updates?: string[];
146
176
  visible?: boolean;
147
177
  filters?: Record<string, {
@@ -150,6 +180,7 @@ export type SubscriptionSelection = {
150
180
  }>;
151
181
  selection?: SubscriptionSelection;
152
182
  abstract?: boolean;
183
+ abstractHasRequired?: boolean;
153
184
  };
154
185
  };
155
186
  abstractFields?: {
@@ -172,7 +203,7 @@ export type FetchQueryResult<_Data> = {
172
203
  result: RequestPayload<_Data | null>;
173
204
  source: DataSources | null;
174
205
  };
175
- export type QueryResult<_Data = GraphQLObject, _Input = Record<string, any>> = {
206
+ export type QueryResult<_Data = GraphQLObject, _Input = GraphQLVariables> = {
176
207
  data: _Data | null;
177
208
  errors: {
178
209
  message: string;
@@ -191,7 +222,7 @@ export type RequestPayload<GraphQLObject = any> = {
191
222
  };
192
223
  export type NestedList<_Result = string> = (_Result | null | NestedList<_Result>)[];
193
224
  export type ValueOf<Parent> = Parent[keyof Parent];
194
- export declare const fragmentKey = " $fragments";
225
+ export declare const fragmentKey: " $fragments";
195
226
  export type ValueNode = VariableNode | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ListValueNode | ObjectValueNode;
196
227
  export type ValueMap = Record<string, ValueNode>;
197
228
  export type FetchParams<_Input> = {
@@ -283,4 +314,6 @@ interface VariableNode {
283
314
  readonly kind: 'Variable';
284
315
  readonly name: NameNode;
285
316
  }
317
+ export declare const PendingValue: unique symbol;
318
+ export type LoadingType = typeof PendingValue;
286
319
  export {};
@@ -29,6 +29,7 @@ const DataSource = {
29
29
  Ssr: "ssr"
30
30
  };
31
31
  const fragmentKey = " $fragments";
32
+ const PendingValue = Symbol("houdini_loading");
32
33
  export {
33
34
  ArtifactKind,
34
35
  CachePolicy,
@@ -38,6 +39,7 @@ export {
38
39
  CompiledSubscriptionKind,
39
40
  DataSource,
40
41
  PaginateMode,
42
+ PendingValue,
41
43
  RefetchUpdateMode,
42
44
  fragmentKey
43
45
  };
@@ -9,3 +9,18 @@ export type Partial<T> = {
9
9
  export declare function pipelineTest(config: Config, documents: string[], shouldPass: boolean, testBody?: ((result: Error | Error[]) => void) | ((docs: Document[]) => void)): () => Promise<void>;
10
10
  export declare function mockCollectedDoc(query: string, data?: Partial<Document>): Document;
11
11
  export declare function clearMock(): void;
12
+ export type Row = {
13
+ title: string;
14
+ pass: true;
15
+ documents: string[];
16
+ check?: (docs: Document[]) => void;
17
+ partial_config?: Partial<Config>;
18
+ nb_of_fail?: number;
19
+ } | {
20
+ title: string;
21
+ pass: false;
22
+ documents: string[];
23
+ check?: (result: Error | Error[]) => void;
24
+ partial_config?: Partial<Config>;
25
+ nb_of_fail?: number;
26
+ };