feature/IO-3000-messaging-sockets-migration2 -

- Various work

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-11-28 09:57:35 -08:00
parent 08c0da1bed
commit db5740d487
5 changed files with 40 additions and 9 deletions

View File

@@ -145,14 +145,34 @@ middlewares.push(
const cache = new InMemoryCache({
typePolicies: {
Query: {
conversations: {
fields: {
conversations: offsetLimitPagination()
job_conversations: {
merge(existing = [], incoming = [], { readField }) {
const merged = new Map();
// Add existing data to the map
existing.forEach((jobConversation) => {
// Use `readField` to get the unique `jobid`, fallback to `__ref`
const jobId = readField("jobid", jobConversation) || jobConversation.__ref;
if (jobId) merged.set(jobId, jobConversation);
});
// Add or replace with incoming data
incoming.forEach((jobConversation) => {
// Use `readField` to get the unique `jobid`, fallback to `__ref`
const jobId = readField("jobid", jobConversation) || jobConversation.__ref;
if (jobId) merged.set(jobId, jobConversation);
});
// Return the merged data as an array
return Array.from(merged.values());
}
}
}
}
}
});
const client = new ApolloClient({
link: ApolloLink.from(middlewares),
cache,