@trackunit/react-graphql-hooks 0.0.13 → 0.0.15
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.
- package/index.cjs.js +11 -2
- package/index.esm.js +11 -2
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -162,10 +162,19 @@ const usePaginationQuery = (document, props) => {
|
|
|
162
162
|
/**
|
|
163
163
|
* To support pagination with page and pageSize, we need to convert the variables from first and after.
|
|
164
164
|
*/
|
|
165
|
-
|
|
165
|
+
let fetchMoreVariables = Object.assign(Object.assign({}, props.variables), (props.variables && "page" in props.variables && "pageSize" in props.variables
|
|
166
166
|
? // eslint-disable-next-line local-rules/no-typescript-assertion
|
|
167
167
|
{ pageSize: variables.first, page: Number(variables.after) || 0 }
|
|
168
168
|
: Object.assign({}, variables)));
|
|
169
|
+
// To support "pageable" queries we do it here! REMOVE once the serviceplans are updated to use the new pagination.
|
|
170
|
+
fetchMoreVariables = Object.assign({}, ("pageable" in fetchMoreVariables
|
|
171
|
+
? Object.assign(Object.assign({}, fetchMoreVariables), { pageable: {
|
|
172
|
+
first: fetchMoreVariables.first,
|
|
173
|
+
last: fetchMoreVariables.last,
|
|
174
|
+
before: fetchMoreVariables.before,
|
|
175
|
+
after: fetchMoreVariables.after,
|
|
176
|
+
pageSize: fetchMoreVariables.pageSize,
|
|
177
|
+
} }) : Object.assign({}, fetchMoreVariables)));
|
|
169
178
|
fetchMore({
|
|
170
179
|
variables: fetchMoreVariables,
|
|
171
180
|
updateQuery: (_, { fetchMoreResult }) => {
|
|
@@ -194,7 +203,7 @@ const usePaginationQuery = (document, props) => {
|
|
|
194
203
|
setData(undefined);
|
|
195
204
|
}, [props.variables]);
|
|
196
205
|
react.useEffect(() => {
|
|
197
|
-
const abortController = doFetchMore({ first
|
|
206
|
+
const abortController = doFetchMore({ first, last: undefined, before: undefined, after: undefined }, undefined);
|
|
198
207
|
return () => {
|
|
199
208
|
abortController.abort();
|
|
200
209
|
};
|
package/index.esm.js
CHANGED
|
@@ -138,10 +138,19 @@ const usePaginationQuery = (document, props) => {
|
|
|
138
138
|
/**
|
|
139
139
|
* To support pagination with page and pageSize, we need to convert the variables from first and after.
|
|
140
140
|
*/
|
|
141
|
-
|
|
141
|
+
let fetchMoreVariables = Object.assign(Object.assign({}, props.variables), (props.variables && "page" in props.variables && "pageSize" in props.variables
|
|
142
142
|
? // eslint-disable-next-line local-rules/no-typescript-assertion
|
|
143
143
|
{ pageSize: variables.first, page: Number(variables.after) || 0 }
|
|
144
144
|
: Object.assign({}, variables)));
|
|
145
|
+
// To support "pageable" queries we do it here! REMOVE once the serviceplans are updated to use the new pagination.
|
|
146
|
+
fetchMoreVariables = Object.assign({}, ("pageable" in fetchMoreVariables
|
|
147
|
+
? Object.assign(Object.assign({}, fetchMoreVariables), { pageable: {
|
|
148
|
+
first: fetchMoreVariables.first,
|
|
149
|
+
last: fetchMoreVariables.last,
|
|
150
|
+
before: fetchMoreVariables.before,
|
|
151
|
+
after: fetchMoreVariables.after,
|
|
152
|
+
pageSize: fetchMoreVariables.pageSize,
|
|
153
|
+
} }) : Object.assign({}, fetchMoreVariables)));
|
|
145
154
|
fetchMore({
|
|
146
155
|
variables: fetchMoreVariables,
|
|
147
156
|
updateQuery: (_, { fetchMoreResult }) => {
|
|
@@ -170,7 +179,7 @@ const usePaginationQuery = (document, props) => {
|
|
|
170
179
|
setData(undefined);
|
|
171
180
|
}, [props.variables]);
|
|
172
181
|
useEffect(() => {
|
|
173
|
-
const abortController = doFetchMore({ first
|
|
182
|
+
const abortController = doFetchMore({ first, last: undefined, before: undefined, after: undefined }, undefined);
|
|
174
183
|
return () => {
|
|
175
184
|
abortController.abort();
|
|
176
185
|
};
|