I'm trying get a new set data from a paginated-like API I created but I only receive the object with the ref property from the cache, but the data from the api. How can I return a array of the existing and incoming data?
const client = new ApolloClient({
ssrMode: typeof window === undefined,
link: httpLink,
cache: new InMemoryCache({
typePolicies: {
Query: {
fields: {
todos: {
merge(existing, incoming) {
console.log(incoming) // I want the data, not the ref object
return [ ...existing, ...incoming ]
}
}
}
}
}
})
});
photos of the result in console log Result of the Merge Helper Function
useQuery Hook calling the pagination api
if needed I left my repo below
You have access to the cache in the third argument to
merge
, and you can use that to convert the references to data objects.