fix: Apollo Client cache merge causing product duplication
Some checks failed
Build and Deploy / build (push) Has been cancelled

The merge function was concatenating products on each query, causing
4 products to become 8, then 12, etc. Changed to replace incoming
data instead of merging.
This commit is contained in:
Unchained
2026-03-21 18:04:11 +02:00
parent 2876a8f80e
commit 26212dec1c

View File

@@ -24,12 +24,8 @@ export const saleorClient = new ApolloClient({
fields: { fields: {
products: { products: {
keyArgs: ["channel", "filter"], keyArgs: ["channel", "filter"],
merge(existing, incoming) { merge(_existing, incoming) {
if (!existing) return incoming; return incoming;
return {
...incoming,
edges: [...existing.edges, ...incoming.edges],
};
}, },
}, },
}, },