Reference / @getenginex/sdk/query / EnginexMutationOptions
EnginexMutationOptions<TInput, TResult>
Options of an SDK mutation, compatible with TanStack Query v5's useMutation and MutationObserver. invalidates is not TanStack's: the adapter (or the app) invalidates those keys after success.
Example
const createPix = createMutations(enginex).deposits.createPix()
const pix = await createPix.mutationFn({ amount: 5000 })
for (const queryKey of createPix.invalidates({ amount: 5000 }, pix)) {
await queryClient.invalidateQueries({ queryKey })
}Type Parameters
TInput
TInput
TResult
TResult
Properties
gcTime?
optionalgcTime?:number
The mutation's gcTime in TanStack Query: 0 on those that carry credentials or personal data in the input or in the result (auth.*, except logout, and withdrawals.confirmOtp), so that variables and the result leave the MutationCache (and the devtools) as soon as no component observes the mutation. While a component observes it (the mounted useMutation), they stay: call reset() when you no longer need them (e.g. in the login's onError, keeping the error to display in state). Absent on the others.
invalidates
invalidates: (
input,result) => readonly readonlyunknown[][]
Prefixes of the keys that the write leaves stale, built with the session's userId at the moment of the call. Call only after success.
Parameters
input
TInput
result
TResult
Returns
readonly readonly unknown[][]
mutationFn
mutationFn: (
input) =>Promise<TResult>
Calls the SDK method with the input.
Parameters
input
TInput
Returns
Promise<TResult>
mutationKey
mutationKey: readonly
unknown[]
['enginex', namespace, method], without the input.