Skip to content

Commit 97da4c4

Browse files
committed
move template helpers
1 parent 5c11877 commit 97da4c4

File tree

5 files changed

+618
-0
lines changed

5 files changed

+618
-0
lines changed

concat.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { OperationVariables } from '@apollo/client'
2+
3+
export function concatToQuery<T = any>(
4+
key: Exclude<keyof T, '__typename'>,
5+
): (
6+
previousQueryResult: any,
7+
options: { fetchMoreResult?: any; variables?: OperationVariables },
8+
) => any {
9+
return (previousQueryResult, { fetchMoreResult }) => {
10+
if (!fetchMoreResult) return previousQueryResult
11+
return {
12+
...fetchMoreResult,
13+
[key]: {
14+
...fetchMoreResult[key],
15+
nodes: [
16+
...(previousQueryResult[key].nodes || []),
17+
...(fetchMoreResult[key].nodes || []),
18+
],
19+
},
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)