RTKQ Accumulate results and fetch only for missing parameters #3896
-
Hello everyone, To make things simpler, let's say the API consists of a single POST endpoint where it's possible to retrieve elements by id: fetch(
'/my-api',
{ body: { ids: [ 1, 2, 3 ] }}
) Which returns something like: {
counts: {
1: 'data1',
2: 'data2',
3: 'data3',
}
} Now, I think I could easily model that with a
Having some sort of hooks that returns me a structure like fetch(
'/my-api',
{ body: { ids: [ 4, 5 ] }}
) and have the final hook to return all the fetched ids so far (so also 1, 2, 3). I don't need the API slice to find out what ids are missing, I can do it myself with a custom hook, but I need to have a way to accumulate all retrieved data and get all at once with a hook. Do you think it's possible to implement this interaction with RTKQ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
That doesn't sound like something that RTKQ is well suited for. It's designed to be a "document cache", storing exactly what was sent back by the server (possibly modified by |
Beta Was this translation helpful? Give feedback.
That doesn't sound like something that RTKQ is well suited for. It's designed to be a "document cache", storing exactly what was sent back by the server (possibly modified by
transformResponse
). It sounds like you're asking for something more along the lines of a "normalized cache", like Apollo or Urql