Replies: 1 comment 5 replies
-
Some high-level summary answers:
|
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
1. General concern
What I am painfully missing in RTK-query documentation is an advice on how to grow rtk-query slices in a medium to large-scale application. Specifically:
createApi
function?createApi
expected to be mentally mapped to the backends that the client queries? For example, if there are three different backend microservices that the client talks to, would one expect to have three rtk-query api slices?action-listener-middleware
is intended for, or is this a problem that rtk-query solves on its own? UPDATED: found an answer to this question in the docs.injectEndpoints
method, then is there any way to avoid naming collisions, other than following some internal naming conventions within the development team?2. Example: specific pain point
Here is a simplified scenario based on an application I am working on. Suppose we have an app that combines multiple instruments for exploring genes. The app is split into several large parts; let's call them genome viewer, gene viewer, and sequence viewer. Each part has multiple screens.
The app uses multiple backend apis; but let's consider just one, which is a graphql api.
So, suppose, we structure the app like this:
First, create a rtk-query api for talking to the graphql backend
Then, use this newly created
myGraphqlApi
in a slice responsible for queries for the genome viewerAs well as, in a different slice, responsible for queries for the gene viewer
Uh-oh! We have a problem. There is a name collision between injected endpoints — both are called geneSummary. But it's completely natural to expect that in the
genome-view
part of my app I can request a gene summary that will have one set of fields, whereas in thegene-view
part of my app I can request a gene summary with an entirely different set of fields. Both of them are gene summaries, but they exist within different contexts. Does this mean that I should have created a "genome view api" and a "gene view api" instead of a "my graphql api"? What if each of the views also talks to different backends — would I end up with a "genome view graphql api", "genome view rest api", "gene view graphql api", and "gene view rest api", and so on?I hope you can appreciate my confusion. Please, could you kindly advise?
Beta Was this translation helpful? Give feedback.
All reactions