Reference / @getenginex/sdk/query / createQueries
createQueries()
createQueries(
client):CoreQueries
Creates the core query factories over a client: one per read method, with the same name and the same input as the method (q.wallet.getBalance(), q.wallet.listTransactions({ page })). Each call returns { queryKey, queryFn }, compatible with TanStack Query v5's useQuery/prefetchQuery/fetchQuery, without the SDK depending on it. It makes no request: call it once per client.
- Reads without a session (
config.*): key['enginex', 'public', namespace, method, input?]and astaleTimeof 5 minutes (the configuration rarely changes). No other read has astaleTime. - Player reads: key
['enginex', 'user', userId, namespace, method, input?], with the session'suserIdat the moment the factory is called. Without a session, the key uses'anonymous'and thequeryFnrejects withUNAUTHENTICATEDwithout making a request; the same happens if the session changes user before thefetch. Call the factory again after login (the React adapter does this). queryFnpasses the context'ssignalon inoptions.signal: cancelling the query aborts thefetch.inputonly goes in the key when given; no key contains a token or password.
Parameters
client
The client returned by createEnginexClient.
Returns
Example
ts
import { useQuery } from '@tanstack/react-query'
import { createQueries } from '@getenginex/sdk/query'
const q = createQueries(enginex)
const balance = useQuery({ ...q.wallet.getBalance(), refetchInterval: 10_000 })
await queryClient.prefetchQuery(q.config.get())Throws
CONFIGURATION_ERROR if client has no session.get() (it is not an SDK client).