Comments (4)
I haven't fully looked at this admittedly, but looking at this, are you referring to tags
i.e. a scalar list of string[]
/ [String]
?
If so, if you have two queries that, instead of defining fragments and hoisting & spreading them in a single query, load the same scalar field then the two values cannot be equal.
This is because two queries will launch two operations that will both be fulfilled by the API, even if they overlap. In turn, this means that tags: [String]
will be loaded twice and the resulting value, given that it's a reference, is not normalised and can never be reference equal to itself — i.e. since it's unrealistic to expect them to be deeply compared, since we treat all scalars as opaque values, they'll never be equal once they've been fetched from the API twice.
This could of course be prevented by somehow treating API results in a special manner and assuming that they're JSON-equal, and comparing that. However, this would have a significant impact on the performance of cache reads. After all, the cache reads are expected to visit each field in the query AST and process them.
So, I don't think that this is behaviour that's unexpected, and I'd recommend you to — if you expect this to behave differently in a real app — to hoist and combine queries as much as possible and otherwise either make sure that you deep-diff parts of data where you need (which of course shouldn't be needed often) or strategically memoise rendering results or computed values.
Sorry if that's not the answer you were looking for though!
from urql.
Thanks for the reply. In the reproduction, individual Todo
(query TodoDetail
) does not include tags
, but when query TodoDetail
is executed, tags
in TodoList
is updated.
I think there might be a case that the client want to retrieve non-detailed list for the performance reason (server dependent, maybe), so the reproduction pattern would be a possible case.
from urql.
Yea, the reason is because the List of strings is seen as updated which is being queried from the list, and afterwards from the details/... Tbh, I would not really see this as a bug as much as a maybe-optimization but I reckon comparing those lists is more expensive than just doing a React-render that bails out anyway as it sees no changes.
from urql.
I am going to close this out as we can't really make assumptions about these scalars, generally speaking the issue would be here where the array reference isn't the same, this makes sense but we can't really deep compare as this could be a Date
, ...
from urql.
Related Issues (20)
- Graphcache cache invalidation no longer working within optimistic update HOT 3
- `@urql/next` publishes CommonJS with invalid React usages HOT 1
- RFC: Option to hide warnings when in development
- Infinite initialization? (with Graphql-codegen and Next.js 13) HOT 4
- RFC: Add APQ support for Contentful (CMS) HOT 3
- persistedExchange(APQ) doesn't work with cacheExchange due to Document Caching HOT 2
- RFC: Add `onCacheHydrated` event
- RFC (Graphcache): Change SerializedEntries to provide Map to storage adapters HOT 3
- Component does not suspend when changing variables while using `suspense: true`
- RangeError: Maximum call stack size exceeded when using persistedExchange in front of ssrExchange HOT 7
- Saving a component in Next.js development mode casues infinite requests HOT 1
- Stale || Fetching doesn't actually represent when operations are in progress while offline HOT 5
- storage missing in typed graphcache HOT 3
- Request Policy set to cache-only throws error during build of next.js app with document cache
- request-policy-exchange behavior differs between dev & production HOT 2
- @urql/next registerUrql fails in Next.js app due to TypeError: React.cache is not a function HOT 1
- reexecuteQuery not using new variables HOT 1
- RFC: Consolidating document and normalised caching - safer caching
- [Network] Load failed. Requests are failing on mobile and safari (Safari on both desktop and mobile, and on mobile chrome) HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from urql.