I have an upsert request that runs when I create or update. When updating, Apollo integrates the result into the cache, but not on its creation.
Here is the request:
export const UPSERT_NOTE_MUTATION = gql` mutation upsertNote($id: ID, $body: String) { upsertNote(id: $id, body: $body) { id body } }`
My client:
const graphqlClient = new ApolloClient({ networkInterface, reduxRootSelector: 'apiStore', dataIdFromObject: ({ id }) => id });
The response from the server is identical: both id
and body
are returned, but Apollo does not automatically add new identifiers to the data
cache object.
Is it possible that Apollo will automatically add new objects to the data
without causing further fetching?
Here's what my data warehouse looks like:

UPDATE
According to the documentation, the updateQueries
function should allow me to insert a new item into my list of assets without having to repeat the query to select the source origin.
The function is executed, but everything that is returned by the function is completely ignored and the cache does not change.
Even if I do something like this:
updateQueries: { getUserAssets: (previousQueryResult, { mutationResult }) => { return {}; } }
Nothing changes.
UPDATE # 2
Still unable to update my asset list.
Inside updateQueries
this is what my previousQueryResult
looks like:
updateQueries: { getUserAssets: (previousQueryResult, { mutationResult }) => { return { assets: [] .concat(mutationResult.data.upsertAsset) .concat(previousQueryResult.assets) } } }
But no matter what I return, the data store is not updated:

For reference, here is what each asset
looks like:
