fix: Apollo Client cache merge causing product duplication
Some checks failed
Build and Deploy / build (push) Has been cancelled
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:
@@ -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],
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user