modelenceQuery<Defined in: index.ts:108 Creates query options for use with TanStack Query’s useQuery hook.T>(methodName,args):object
Example
Type Parameters
Parameters
Returns
object
Query options object for TanStack Query’s useQuery
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
modelenceQuery<Defined in: index.ts:108 Creates query options for use with TanStack Query’s useQuery hook.T>(methodName,args):object
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 Parameter | Default type | Description |
|---|---|---|
T | unknown | The expected return type of the query |
| Parameter | Type | Description |
|---|---|---|
methodName | string | The name of the method to query |
args | Args | Optional arguments to pass to the method |
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 |