-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
rtk-query: endpoint name clashes in a big app #3350
Comments
What would happen if the key is accidentally the same? What's the benefit of that over prefixing your endpoint names, for example? ( additionally, each endpoint is exposed as
Hot module replacement could be one example where you would want to allow overriding the existing definition of the same name. #3157 |
I see... yeah, I've dug into the code a bit and now I can see it a bit more clearly... |
cool - if you have any ideas for how to make the docs any clearer, I'm sure a PR would be welcome :) |
I'll check if i indeed was not getting a warning about the same endpoint names |
You should get warnings as long as you use the development build - we strip the warning in production to save on size. Generally, I'd recommend longer endpoint names and aliasing the hook on export. As for
|
this works for me personally, and for my pet app, for example. However, I think I'll have to come up with some sort of a custom lint rule to make people in the big app aware of the fact that they should use "descriptive" endpoint names. ideally, I'd love it if the names wouldn't clash at all, like if each |
This is a standard JS ecosystem idiom for "only do this in development mode builds", yes: |
As for It gets even more frustrating considering that there is also |
While researching on how to deal with endpoint name duplication, i stumbled on this issue.
|
@markerikson in our case for a larger application, we have never wanted to override the endpoint. In this case, it would be preferrable to throw an error, as we wouldn't want teams accidentally changing each other's function signatures. Though this is rare, do you think it could justify having a way to throw an error on override to prevent unintentional use leaking to production for applications like this? Something akin to - overrideExisting: 'throw' |
I have the same problem "getSupplierData" and "getSupplier" names are conflicting. |
@ffluk3 if you wanted to get a PR together with that option, I doubt we'd be against it :) |
@EskiMojo14 I've thrown up a solution here and am happy to help take it through the review cycle! |
I'm converting a fairly big app to rtk-q. the app is heavily split into "features" and each feature is lazy-loaded, so we're using
injectEndpoints
. Different features are developed by different teams so it was just a matter of time before we started getting endpoint clashes with different features having something likeuseFetchDataQuery
oruseUpdateDataMutation
Do you think we can do something about it? :) Like add an optional
key
toinjectEndpoints
?Additionally, I don't fully understand theok according to the doc it should've warned me in dev env, but for some reason it didn'toverrideExisting
option. With it being false by default it was rather surprising and tricky to track down why a wrong network call was suddenly made in a different part of the app.Frankly, I don't really understand the use case of either
overrideExisting
set to true or false. Why would it be ok to disregard the fact that the endpoint names clash?The text was updated successfully, but these errors were encountered: