-
Hi, I am just getting started with urql and moving over from Apollo. Really love urql so far, really nice job! I am trying to implement endless scrolling in my app, and while I can get the data to be fetched correctly (with simplePagination), everytime it rerenders the entire list instead of keeping the previous results and just adding the new items. I believe it is because each time it fetches new data, then it saves it as a separate data structure in the normalized cache (e.g. first time it is recipe(limit: 5, offset: 0), second time it is recipe(limit:5, offset:5) but that one includes the first). Hope it makes sense, essentially what I am looking for is that only the new data is rendered and the old data stay mounted (as if everyting rerenders, then the user gets pushed up to the start of the list everytime). cacheExchange:
Query:
Flatlist:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is expected behaviour; each time a query is made against Graphcache it has to walk its normalized data and constructs a new result from scratch, as if it was basically queried anew against a server. That also means that all data will essentially not have the same references as before. Unintuitively this is much faster than preserving any instances due to the data structure that is needed to store normalized data. They're simply consistent of records and links between entities. What we'd have to do if we wanted to preserve previous structure is to do a lot of deep comparisons. However, because this adds an added non-trivial cost it doesn't make much sense for Instead, what we'd recommend is to rely on
|
Beta Was this translation helpful? Give feedback.
This is expected behaviour; each time a query is made against Graphcache it has to walk its normalized data and constructs a new result from scratch, as if it was basically queried anew against a server.
That also means that all data will essentially not have the same references as before. Unintuitively this is much faster than preserving any instances due to the data structure that is needed to store normalized data. They're simply consistent of records and links between entities.
What we'd have to do if we wanted to preserve previous structure is to do a lot of deep comparisons. However, because this adds an added non-trivial cost it doesn't make much sense for
urql
to do this globally …