TanStackT
TanStack3mo ago
1 reply
moderate-tomato

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")
        }
    },
})


i can see the update log so it goes into the
if
and the transaction has note to
null
Was this page helpful?