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: {
|
||||
products: {
|
||||
keyArgs: ["channel", "filter"],
|
||||
merge(existing, incoming) {
|
||||
if (!existing) return incoming;
|
||||
return {
|
||||
...incoming,
|
||||
edges: [...existing.edges, ...incoming.edges],
|
||||
};
|
||||
merge(_existing, incoming) {
|
||||
return incoming;
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user