Skip to content

rtk-query: Modify refetchOnMountOrArgChange with enhanceEndpoints #2333

@ericecook

Description

@ericecook

I'm using codegen to generate the api spec and would like to specify a refetchOnMountOrArgChange for the whole endpoint - rather than in every component.

Ideally I'd like to do something like

import { injectedApi } from './generated/api'

const enhancedRtkApi = injectedApi.enhanceEndpoints({
    getData: {
      refetchOnMountOrArgChange: 600,
      keepUnusedDataFor: 14400,
    },
  },
})
export { enhancedRtkApi as api }

But it looks like refetchOnMountOrArgChange is part of the query key. I may be missing something, but I couldn't figure out a way to pass query key w/o overriding the generated one

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions