Using updateQueryData in injectEndpoints #1299
Unanswered
dorbaruchh
asked this question in
Q&A
Replies: 1 comment 8 replies
-
Even in your original code, you should just be able to |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I have the following code to create an API using the recommended approach described in the "Code Splitting" section:
Main API:
Injecting additional endpoints to main API:
As you can see, inside the markNotificationsRead endpoint I have a call to updateQueryData with the endpoint name "getNotifications" which is also defined above in the same API.
Doing so, I get the following error for the endpoint parameter in the updateQueryData call: "Argument of type 'string' is not assignable to parameter of type 'never'."
I am very new to Typescript so I'm not completely sure what the issue is.
I suspect that the issue is that my original API was created without any endpoints so when calling updateQueryData we can't type check that getNotifications is really a valid endpoint name.
Assuming this is really the issue, is there any way to fix it without having to move the getNotifications definition to the main API definition?
One option I tried is to split the injected API to 2, like so:
Would this be the recommended approach?
Thank you in advance for the help!
Beta Was this translation helpful? Give feedback.
All reactions