This version (v0.7) has not been published to npm yet.
Skip to content

Reference / @getenginex/sdk/query / enginexKeys

enginexKeys ​

const enginexKeys: EnginexKeys

Prefixes of the SDK's query keys (see EnginexQueryKey). The fixed prefixes are frozen.

The ['enginex', 'user', userId, namespace, method, input?] layout is a contract. For setQueryData, the exact key is the factory's (q.wallet.getBalance().queryKey), not the prefix.

Example ​

ts
import { enginexKeys } from '@getenginex/sdk/query'

// After logout or a user switch: nothing from the previous user stays in the cache.
queryClient.removeQueries({ queryKey: enginexKeys.user() })
// Everything for the current player.
queryClient.invalidateQueries({ queryKey: enginexKeys.user(session.userId) })
// Only the wallet, or only the balance.
queryClient.invalidateQueries({ queryKey: enginexKeys.user(session.userId, 'wallet') })
queryClient.invalidateQueries({ queryKey: enginexKeys.user(session.userId, 'wallet', 'getBalance') })
// Exact key for setQueryData: the factory's.
queryClient.setQueryData(createQueries(client).wallet.getBalance().queryKey, balance)