Skip to content

@rtk-query/codegen-openapi and transformResponse #3506

Answered by EskiMojo14
nhayfield asked this question in Q&A
Discussion options

You must be logged in to vote

you would need to use enhanceEndpoints.

1.9.4+

currently changing the ResultType of an endpoint is fairly complicated:

import type { DefinitionsFromApi, TagTypesFromApi, OverrideResultType } from "@reduxjs/toolkit/dist/query/endpointDefinitions"
import { api } from "./autogenerated"

type Definitions = DefinitionsFromApi<typeof api>
type TagTypes = TagTypesFromApi<typeof api>

type UpdatedGetPostsDef = OverrideResultType<Definitions["getPosts"], EntityState<Post>>

type UpdatedDefinitions = Omit<Definitions, { getPosts: UpdatedGetPostsDef }>

const enhanced = api.enhanceEndpoints<TagTypes, UpdatedDefinitions>({
  endpoints: {
    getPosts: {
      transformResponse: (posts) => postAdapter.s…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@andreyantipov
Comment options

@EskiMojo14
Comment options

Answer selected by nhayfield
Comment options

You must be logged in to vote
1 reply
@EskiMojo14
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants