T
TanStack2mo ago
afraid-scarlet

setQueryData doesn't trigger an update

i have a transaction with a note field. everything works fine when i add a note. but when i use a graphql mutation to remove the note with null i receive the callback and do a setQueryData but that doesn't re-trigger an update on react side with the note to null i have to pull to refresh. am i missing something this is what i do
export const transactionUpdateOptions = makeMutationOptions(TransactionUpdateMutation, {
onSuccess: (data) => {
if (data.transactions_update.__typename === "TransactionsUpdateSuccess") {
const transaction = data.transactions_update.transaction
queryClient.setQueryData(["GetTransactionQuery", { id: transaction.id }], { transaction })
console.log("update")
}
},
})
export const transactionUpdateOptions = makeMutationOptions(TransactionUpdateMutation, {
onSuccess: (data) => {
if (data.transactions_update.__typename === "TransactionsUpdateSuccess") {
const transaction = data.transactions_update.transaction
queryClient.setQueryData(["GetTransactionQuery", { id: transaction.id }], { transaction })
console.log("update")
}
},
})
i can see the update log so it goes into the if and the transaction has note to null
1 Reply
afraid-scarlet
afraid-scarletOP2mo ago
when i add a note, it trigger properly and i see the update render on react side in my components but on the delete, i see the update log but no re-render is triggered but if i log transaction i can see that the note is null

Did you find this page helpful?