Reference / @getenginex/sdk-igaming/query / createIgamingMutations
createIgamingMutations()
createIgamingMutations(
igaming):IgamingMutations
Creates the iGaming mutations: one per write method, with the same name as the method (m.loyalty.redeem()). Each call returns { mutationKey, mutationFn, invalidates }, compatible with TanStack Query v5's useMutation; invalidates(input, result) lists the prefixes the write leaves stale (with the session's userId at call time; call it only after success):
bonus.optIn/claim/redeemPromoCode→bonusandwallet(the core's balance);loyalty.redeem→loyaltyandwallet;referrals.register→referrals;casino.launchGame→casino.listSessions;bonus.resolvePromoCodeandsportsbook.createSession→ nothing.
mutationKey is ['enginex', namespace, method], without the input. The ones that send Idempotency-Key (bonus.optIn/claim/redeemPromoCode, loyalty.redeem) reuse the key only after an ambiguous failure (network, timeout, 5xx, KEY_IN_USE or VALIDATION_ERROR after a 2xx) with the same input, on this options object (see the core's createMutations), and accept { idempotencyKey } on the factory. The ones that carry credentials in the input or the result (promo code, game URL, sportsbook session) have gcTime: 0.
Parameters
igaming
The object returned by createIgaming(enginex) (the object itself, not a copy).
Returns
Example
import { useMutation } from '@tanstack/react-query'
import { createIgamingMutations } from '@getenginex/sdk-igaming/query'
const m = createIgamingMutations(igaming)
const redeem = m.loyalty.redeem()
const result = await redeem.mutationFn({ points: 500, redemptionType: 'bonus' })
for (const queryKey of redeem.invalidates({ points: 500, redemptionType: 'bonus' }, result)) {
await queryClient.invalidateQueries({ queryKey })
}Throws
CONFIGURATION_ERROR if igaming did not come from createIgaming.