Created
December 19, 2025 14:38
-
-
Save broguinn/bd6f45199b1fe6651359130bb6397d2a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/packages/shared/src/utils/apollo.ts b/packages/shared/src/utils/apollo.ts | |
| index 3f3ab69c..d6301226 100644 | |
| --- a/packages/shared/src/utils/apollo.ts | |
| +++ b/packages/shared/src/utils/apollo.ts | |
| @@ -1,8 +1,15 @@ | |
| export function buildGenericConnectionMerge() { | |
| return { | |
| - keyArgs: () => ['filters'], | |
| - merge(existing: any, incoming: any, { readField }: any) { | |
| - const edges = existing ? { ...existing.edges } : {}; | |
| + keyArgs: ['filters'], | |
| + merge(existing: any, incoming: any, { args, readField }: any) { | |
| + // If no cursor (first page/fresh query), replace existing data | |
| + // If cursor exists (pagination), merge with existing | |
| + const isFirstPage = !args?.cursor; | |
| + let edges = {}; | |
| + if (!isFirstPage && existing) { | |
| + edges = { ...existing.edges }; | |
| + } | |
| + | |
| incoming.edges.forEach((edge: any) => { | |
| edges[readField('id', edge) as string] = edge; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment