We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Codesandbox: https://codesandbox.io/s/redux-toolkit-rtk-query-forked-6plwhy?file=/src/services/pokemon.ts
Somebody had already fixed similar issues, but it was still a problem.
Actual behavior: When you add transformResponse to enhanceEndpoints, ResultType doesn't change according to transformResponse ReturnType.
Expected behavior: ResultType should be matched with transformReposponse ReturnType.
Version: 1.9.7
The text was updated successfully, but these errors were encountered:
see #2953 - the mechanism for overriding resulttype for enhanced endpoints is finicky.
currently you need to do a lot of manual work:
import type { DefinitionsFromApi, OverrideResultType, TagTypesFromApi } from "@reduxjs/toolkit/dist/query/endpointDefinitions"; import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; export const pokemonApi = createApi({ baseQuery: fetchBaseQuery({ baseUrl: "https://pokeapi.co/api/v2/" }), endpoints: (builder) => ({ getPokemonByName: builder.query<object, string>({ query: (name: string) => `pokemon/${name}` }) }) }); type TagTypes = TagTypesFromApi<typeof pokemonApi>; type Definitions = DefinitionsFromApi<typeof pokemonApi>; type UpdatedGetPokemonByName = OverrideResultType< Definitions["getPokemonByName"], number >; type FinalDefinitions = Omit<Definitions, "getPokemonByName"> & UpdatedGetPokemonByName; // Export hooks for usage in functional components export const { useGetPokemonByNameQuery } = pokemonApi.enhanceEndpoints< TagTypes, FinalDefinitions >({ endpoints: { getPokemonByName: { transformResponse: (): number => 1 } } });
In order to better support this, we would need to take more drastic (breaking) changes to enhanceEndpoints (see #3485 for what that might look like)
Sorry, something went wrong.
No branches or pull requests
Codesandbox: https://codesandbox.io/s/redux-toolkit-rtk-query-forked-6plwhy?file=/src/services/pokemon.ts
Somebody had already fixed similar issues, but it was still a problem.
Actual behavior:
When you add transformResponse to enhanceEndpoints, ResultType doesn't change according to transformResponse ReturnType.
Expected behavior:
ResultType should be matched with transformReposponse ReturnType.
Version: 1.9.7
The text was updated successfully, but these errors were encountered: