Built-in Namespacing for injectEndpoints to Prevent Endpoint Name Collisions #5220
-
|
Hi, We’re using a single The problemAll injected endpoints live in a flat namespace on the API instance. This makes collisions easy and silent: // users/api.ts
baseApi.injectEndpoints({
endpoints: (builder) => ({
getById: builder.query(...)
})
})
// orders/api.ts
baseApi.injectEndpoints({
endpoints: (builder) => ({
getById: builder.query(...) // silently overwrites users.getById
})
})This causes:
With large teams and many domains, this becomes a correctness issue rather than just DX. Feature idea / questionIs there (or could there be) a built-in way to namespace injected endpoints, for example: baseApi.injectEndpoints({
namespace: 'users',
endpoints: (builder) => ({
getById: builder.query(...)
})
})or baseApi.injectEndpoints({
endpoints: {
users: (builder) => ({
getById: builder.query(...)
})
}
})With behavior like:
Thanks for the great work on RTK Query - it’s been solid at scale so far. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
#4975