Documentation Index
Fetch the complete documentation index at: https://docs.modelence.com/llms.txt
Use this file to discover all available pages before exploring further.
API Reference / @modelence/react-query / modelenceQuery
modelenceQuery<T>(methodName, args): object
Defined in: index.ts:108
Creates query options for use with TanStack Query’s useQuery hook.
Example
import { useQuery } from '@tanstack/react-query';
import { modelenceQuery } from '@modelence/react-query';
function MyComponent() {
// Basic usage
const { data } = useQuery(modelenceQuery('todo.getAll'));
// With additional options
const { data: todo } = useQuery({
...modelenceQuery('todo.getById', { id: '123' }),
enabled: !!id,
staleTime: 5 * 60 * 1000,
});
return <div>{data?.name}</div>;
}
Type Parameters
| Type Parameter | Default type | Description |
|---|
T | unknown | The expected return type of the query |
Parameters
| Parameter | Type | Description |
|---|
methodName | string | The name of the method to query |
args | Args | Optional arguments to pass to the method |
Returns
object
Query options object for TanStack Query’s useQuery
| Name | Type | Defined in |
|---|
queryFn() | () => Promise<T> | index.ts:114 |
queryKey | (string | Args)[] | index.ts:113 |