houdini 1.1.4-react.0 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/build/cmd-cjs/index.js +607 -444
  2. package/build/cmd-esm/index.js +607 -444
  3. package/build/codegen/transforms/fragmentVariables.d.ts +0 -11
  4. package/build/codegen-cjs/index.js +577 -403
  5. package/build/codegen-esm/index.js +577 -403
  6. package/build/lib/config.d.ts +1 -1
  7. package/build/lib/parse.d.ts +1 -2
  8. package/build/lib/types.d.ts +1 -4
  9. package/build/lib-cjs/index.js +187 -195
  10. package/build/lib-esm/index.js +187 -195
  11. package/build/runtime/cache/cache.d.ts +4 -2
  12. package/build/runtime/client/documentStore.d.ts +0 -3
  13. package/build/runtime/client/index.d.ts +1 -1
  14. package/build/runtime/lib/types.d.ts +4 -46
  15. package/build/runtime-cjs/cache/cache.d.ts +4 -2
  16. package/build/runtime-cjs/cache/cache.js +37 -14
  17. package/build/runtime-cjs/client/documentStore.d.ts +0 -3
  18. package/build/runtime-cjs/client/documentStore.js +6 -11
  19. package/build/runtime-cjs/client/index.d.ts +1 -1
  20. package/build/runtime-cjs/client/plugins/cache.js +3 -5
  21. package/build/runtime-cjs/client/plugins/fragment.js +1 -8
  22. package/build/runtime-cjs/client/plugins/query.js +1 -2
  23. package/build/runtime-cjs/lib/types.d.ts +4 -46
  24. package/build/runtime-esm/cache/cache.d.ts +4 -2
  25. package/build/runtime-esm/cache/cache.js +37 -14
  26. package/build/runtime-esm/client/documentStore.d.ts +0 -3
  27. package/build/runtime-esm/client/documentStore.js +6 -11
  28. package/build/runtime-esm/client/index.d.ts +1 -1
  29. package/build/runtime-esm/client/plugins/cache.js +3 -5
  30. package/build/runtime-esm/client/plugins/fragment.js +1 -8
  31. package/build/runtime-esm/client/plugins/query.js +1 -2
  32. package/build/runtime-esm/lib/types.d.ts +4 -46
  33. package/build/test-cjs/index.js +598 -428
  34. package/build/test-esm/index.js +598 -428
  35. package/build/vite-cjs/index.js +617 -454
  36. package/build/vite-esm/index.js +617 -454
  37. package/package.json +3 -1
  38. package/build/runtime/lib/pageInfo.d.ts +0 -7
  39. package/build/runtime/lib/pagination.d.ts +0 -29
  40. package/build/runtime-cjs/lib/pageInfo.d.ts +0 -7
  41. package/build/runtime-cjs/lib/pageInfo.js +0 -79
  42. package/build/runtime-cjs/lib/pagination.d.ts +0 -29
  43. package/build/runtime-cjs/lib/pagination.js +0 -231
  44. package/build/runtime-esm/lib/pageInfo.d.ts +0 -7
  45. package/build/runtime-esm/lib/pageInfo.js +0 -52
  46. package/build/runtime-esm/lib/pagination.d.ts +0 -29
  47. package/build/runtime-esm/lib/pagination.js +0 -206
@@ -1,206 +0,0 @@
1
- import { getCurrentConfig } from "./config";
2
- import { siteURL } from "./constants";
3
- import { deepEquals } from "./deepEquals";
4
- import { countPage, extractPageInfo, missingPageSizeError } from "./pageInfo";
5
- import { CachePolicy } from "./types";
6
- function cursorHandlers({
7
- artifact,
8
- storeName,
9
- fetchUpdate: parentFetchUpdate,
10
- fetch: parentFetch,
11
- getState,
12
- getVariables,
13
- getSession
14
- }) {
15
- const loadPage = async ({
16
- pageSizeVar,
17
- input,
18
- functionName,
19
- metadata = {},
20
- fetch,
21
- where
22
- }) => {
23
- const config = getCurrentConfig();
24
- const loadVariables = {
25
- ...getVariables(),
26
- ...input
27
- };
28
- if (!loadVariables[pageSizeVar] && !artifact.refetch.pageSize) {
29
- throw missingPageSizeError(functionName);
30
- }
31
- let isSinglePage = artifact.refetch?.mode === "SinglePage";
32
- await (isSinglePage ? parentFetch : parentFetchUpdate)(
33
- {
34
- variables: loadVariables,
35
- fetch,
36
- metadata,
37
- policy: isSinglePage ? artifact.policy : CachePolicy.NetworkOnly,
38
- session: await getSession()
39
- },
40
- isSinglePage ? [] : [where === "start" ? "prepend" : "append"]
41
- );
42
- const resultPath = [...artifact.refetch.path];
43
- if (artifact.refetch.embedded) {
44
- const { targetType } = artifact.refetch;
45
- if (!config.types?.[targetType]?.resolve) {
46
- throw new Error(
47
- `Missing type resolve configuration for ${targetType}. For more information, see ${siteURL}/guides/pagination#paginated-fragments`
48
- );
49
- }
50
- resultPath.unshift(config.types[targetType].resolve.queryField);
51
- }
52
- };
53
- const getPageInfo = () => {
54
- return extractPageInfo(getState(), artifact.refetch?.path ?? []);
55
- };
56
- return {
57
- loadNextPage: async ({
58
- first,
59
- after,
60
- fetch,
61
- metadata
62
- } = {}) => {
63
- const currentPageInfo = getPageInfo();
64
- if (!currentPageInfo.hasNextPage) {
65
- return;
66
- }
67
- const input = {
68
- first: first ?? artifact.refetch.pageSize,
69
- after: after ?? currentPageInfo.endCursor,
70
- before: null,
71
- last: null
72
- };
73
- return await loadPage({
74
- pageSizeVar: "first",
75
- functionName: "loadNextPage",
76
- input,
77
- fetch,
78
- metadata,
79
- where: "end"
80
- });
81
- },
82
- loadPreviousPage: async ({
83
- last,
84
- before,
85
- fetch,
86
- metadata
87
- } = {}) => {
88
- const currentPageInfo = getPageInfo();
89
- if (!currentPageInfo.hasPreviousPage) {
90
- return;
91
- }
92
- const input = {
93
- before: before ?? currentPageInfo.startCursor,
94
- last: last ?? artifact.refetch.pageSize,
95
- first: null,
96
- after: null
97
- };
98
- return await loadPage({
99
- pageSizeVar: "last",
100
- functionName: "loadPreviousPage",
101
- input,
102
- fetch,
103
- metadata,
104
- where: "start"
105
- });
106
- },
107
- async fetch(args) {
108
- const { variables } = args ?? {};
109
- if (variables && !deepEquals(getVariables(), variables)) {
110
- return await parentFetch(args);
111
- }
112
- try {
113
- var currentPageInfo = extractPageInfo(getState(), artifact.refetch.path);
114
- } catch {
115
- return await parentFetch(args);
116
- }
117
- const queryVariables = {};
118
- const count = countPage(artifact.refetch.path.concat("edges"), getState()) || artifact.refetch.pageSize;
119
- if (count && count > artifact.refetch.pageSize) {
120
- if (currentPageInfo.hasPreviousPage && currentPageInfo.hasNextPage && !(variables?.["first"] && variables?.["after"] || variables?.["last"] && variables?.["before"])) {
121
- console.warn(`\u26A0\uFE0F Encountered a fetch() in the middle of the connection.
122
- Make sure to pass a cursor value by hand that includes the current set (ie the entry before startCursor)
123
- `);
124
- }
125
- if (!currentPageInfo.hasPreviousPage) {
126
- queryVariables["first"] = count;
127
- queryVariables["after"] = null;
128
- queryVariables["last"] = null;
129
- queryVariables["before"] = null;
130
- } else if (!currentPageInfo.hasNextPage) {
131
- queryVariables["last"] = count;
132
- queryVariables["first"] = null;
133
- queryVariables["after"] = null;
134
- queryVariables["before"] = null;
135
- }
136
- }
137
- Object.assign(queryVariables, variables ?? {});
138
- const result = await parentFetch({
139
- ...args,
140
- variables: queryVariables
141
- });
142
- return result;
143
- }
144
- };
145
- }
146
- function offsetHandlers({
147
- artifact,
148
- storeName,
149
- getState,
150
- getVariables,
151
- fetch: parentFetch,
152
- fetchUpdate: parentFetchUpdate,
153
- getSession
154
- }) {
155
- let getOffset = () => artifact.refetch?.start || countPage(artifact.refetch.path, getState()) || artifact.refetch.pageSize;
156
- let currentOffset = getOffset() ?? 0;
157
- return {
158
- loadNextPage: async ({
159
- limit,
160
- offset,
161
- fetch,
162
- metadata
163
- } = {}) => {
164
- const queryVariables = {
165
- ...getVariables(),
166
- offset: offset ?? getOffset()
167
- };
168
- if (limit || limit === 0) {
169
- queryVariables.limit = limit;
170
- }
171
- if (!queryVariables.limit && !artifact.refetch.pageSize) {
172
- throw missingPageSizeError("loadNextPage");
173
- }
174
- let isSinglePage = artifact.refetch?.mode === "SinglePage";
175
- const targetFetch = isSinglePage ? parentFetch : parentFetchUpdate;
176
- await targetFetch({
177
- variables: queryVariables,
178
- fetch,
179
- metadata,
180
- policy: isSinglePage ? artifact.policy : CachePolicy.NetworkOnly,
181
- session: await getSession()
182
- });
183
- const pageSize = queryVariables.limit || artifact.refetch.pageSize;
184
- currentOffset = offset + pageSize;
185
- },
186
- async fetch(params = {}) {
187
- const { variables } = params;
188
- if (variables && !deepEquals(getVariables(), variables)) {
189
- return parentFetch.call(this, params);
190
- }
191
- const count = currentOffset || getOffset();
192
- const queryVariables = {};
193
- if (!artifact.refetch.pageSize || count > artifact.refetch.pageSize) {
194
- queryVariables.limit = count;
195
- }
196
- return await parentFetch.call(this, {
197
- ...params,
198
- variables: queryVariables
199
- });
200
- }
201
- };
202
- }
203
- export {
204
- cursorHandlers,
205
- offsetHandlers
206
- };