TanStackT
TanStack2y ago
2 replies
clean-aquamarine

Mutation transformation best practices

Let's say I have a mutate hook that saves a message via a form.

This form has 2 fields, a text field (subject) and a textarea (message).

I need to do some transformation based on conditions prior to sending this payload.

Is it better to:

1. Transform the data at the form level before reaching the mutation hook
2. Transform the data directly in the mutation hook (possibly with onMutate)

?
Was this page helpful?