The API slice object will have an endpoints field inside. This section maps the endpoint names you provided to createApi to the core Redux logic (thunks and selectors) used to trigger data fetches and read cached data for that endpoint. If you're using the React-specific version of createApi, each endpoint definition will also contain the auto-generated React hooks for that endpoint.
Each endpoint structure contains the following fields:
typeInitiateRequestThunk=StartQueryActionCreator|StartMutationActionCreator;typeStartQueryActionCreator= ( arg:any, options?:StartQueryActionCreatorOptions) =>ThunkAction<QueryActionCreatorResult,any,any,AnyAction>;typeStartMutationActionCreator<DextendsMutationDefinition<any,any,any,any>> = ( arg:any options?:StartMutationActionCreatorOptions) =>ThunkAction<MutationActionCreatorResult<D>,any,any,AnyAction>;typeSubscriptionOptions= {/** * How frequently to automatically re-fetch data (in milliseconds). Defaults to `0` (off). */ pollingInterval?:number;/** * Defaults to `false`. This setting allows you to control whether RTK Query will try to refetch all subscribed queries after regaining a network connection. * * If you specify this option alongside `skip: true`, this **will not be evaluated** until `skip` is false. * * Note: requires `setupListeners` to have been called. */ refetchOnReconnect?:boolean;/** * Defaults to `false`. This setting allows you to control whether RTK Query will try to refetch all subscribed queries after the application window regains focus. * * If you specify this option alongside `skip: true`, this **will not be evaluated** until `skip` is false. * * Note: requires `setupListeners` to have been called. */ refetchOnFocus?:boolean;};interfaceStartQueryActionCreatorOptions { subscribe?:boolean; forceRefetch?:boolean|number; subscriptionOptions?:SubscriptionOptions;}interfaceStartMutationActionCreatorOptions {/** * If this mutation should be tracked in the store. * If you just want to manually trigger this mutation using `dispatch` and don't care about the * result, state & potential errors being held in store, you can set this to false. * (defaults to `true`) */ track?:boolean;}
Description
A Redux thunk action creator that you can dispatch to trigger data fetch queries or mutations.
React Hooks users will most likely never need to use these directly, as the hooks automatically dispatch these actions as needed.
:::note Usage of actions outside of React Hooks When dispatching an action creator, you're responsible for storing a reference to the promise it returns in the event that you want to update that specific subscription. Also, you have to manually unsubscribe once your component unmounts. To get an idea of what that entails, see the Svelte Example or the React Class Components Example :::
A function that accepts a cache key argument, and generates a new memoized selector for reading cached data for this endpoint using the given cache key. The generated selector is memoized using Reselect's createSelector.
RTKQ defines a Symbol named skipSelector internally. If skipSelector is passed as the query argument to these selectors, the selector will return undefined. This can be used to avoid returning a value if a given query is supposed to be disabled.
React Hooks users will most likely never need to use these directly, as the hooks automatically use these selectors as needed.
:::caution
Each call to .select(someCacheKey) returns a new selector function instance. In order for memoization to work correctly, you should create a given selector function once per cache key and reuse that selector function instance, rather than creating a new selector instance each time.
:::
Matchers
A set of Redux Toolkit action matching utilities that match the pending, fulfilled, and rejected actions that will be dispatched by this thunk. These allow you to match on Redux actions for that endpoint, such as in createSlice.extraReducers or a custom middleware. Those are implemented as follows: