Skip to content

Exposing the FetchBaseQueryArgs type #4464

New issue

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

Closed
WilsonCWong opened this issue Jun 18, 2024 · 4 comments
Closed

Exposing the FetchBaseQueryArgs type #4464

WilsonCWong opened this issue Jun 18, 2024 · 4 comments

Comments

@WilsonCWong
Copy link
Contributor

Hello,

I recently upgraded from RTK Toolkit 1.9.7, and I noticed that because UMD build artifacts are no longer included, I could not import the FetchBaseQueryArgs like so:

import { FetchBaseQueryArgs } from '@reduxjs/toolkit/dist/query/fetchBaseQuery';

My use case for this is that I have implemented a custom version of fetchBaseQuery at my company that dynamically constructs the URL through various customizable callbacks and options to help us target different projects and environments through our microservices. It looks something like this:

export const fetchDynamicBaseQuery = (
  fetchBaseQueryArgs: FetchBaseQueryArgs,
  options?: DynamicBaseQueryOptions,
): BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError, ExtraOptions> => {
  return async (args, api, extraOptions) => {
    const { baseUrl, ...rest } = fetchBaseQueryArgs;

    let finalBaseUrl = baseUrl;

    // Doing stuff here...

    const rawBaseQuery = fetchBaseQuery({ baseUrl: finalBaseUrl, ...rest });
    return rawBaseQuery(args, api, extraOptions);
  };

Would it be possible to expose this type again? Also open to alternative ways of doing this, but this approach has worked well so far.

@markerikson
Copy link
Collaborator

As a general rule, any time you may have been importing from /dist/ that's accessing internals and it wasn't intentionally exposed :)

That said, we currently do:

export { fetchBaseQuery } from './fetchBaseQuery'
export type {
  FetchBaseQueryError,
  FetchBaseQueryMeta,
  FetchArgs,
} from './fetchBaseQuery'

and I can't think of a reason not to export FetchBaseQueryArgs here.

File a PR to add that?

@WilsonCWong
Copy link
Contributor Author

PR filed! 😃

@EskiMojo14
Copy link
Collaborator

released in v2.2.6 😄

@glasody
Copy link

glasody commented Jul 4, 2024

came looking for this, wasn't disappointed. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants