QueryFactory
For usage after instantiation, see Query.
ChimericQueryFactory
Section titled “ChimericQueryFactory”Creates a ChimericQuery wrapping an RTK Query endpoint.
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';import { ChimericQueryFactory } from '@chimeric/rtk-query';
// 1. Define your RTK Query APIconst api = createApi({ reducerPath: 'api', baseQuery: fetchBaseQuery({ baseUrl: '/api' }), endpoints: (builder) => ({ getUser: builder.query<User, { id: string }>({ query: (params) => `users/${params.id}`, }), getAllTodos: builder.query<Todo[], void>({ query: () => 'todos', }), }),});
// 2. Wrap endpoints with chimeric factoriesconst getUser = ChimericQueryFactory({ store, endpoint: api.endpoints.getUser, endpointName: 'getUser', api,});
const getAllTodos = ChimericQueryFactory({ store, endpoint: api.endpoints.getAllTodos, endpointName: 'getAllTodos', api,});Config
Section titled “Config”| Property | Type | Description |
|---|---|---|
store | Redux store | Store with dispatch and getState |
endpoint | ApiEndpointQuery | RTK Query endpoint (e.g., api.endpoints.getUser) |
endpointName | string | Name of the endpoint |
api | RTK Query API | The createApi result (needed for usePrefetch) |
RTK-Specific Native Options
Section titled “RTK-Specific Native Options”Reactive path:
| Native Option | Type | Description |
|---|---|---|
skip | boolean | RTK Query skip option |
refetchOnMountOrArgChange | boolean | number | RTK refetch behavior |
Idiomatic path:
| Native Option | Type | Description |
|---|---|---|
| (inherits from) | StartQueryActionCreatorOptions | RTK Query initiate options |
IdiomaticQueryFactory
Section titled “IdiomaticQueryFactory”Same config. Returns only the idiomatic callable + .prefetch().
ReactiveQueryFactory
Section titled “ReactiveQueryFactory”Config without store. Returns only .useHook() and .usePrefetchHook().