This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
My app uses Apollo and I keep seeing this problem come up, where two distant components need to query the same entities but different fields in those entities. If each component queries for only what it needs, then caching is ineffective because neither component can reuse the results of the other's queries due to missing fields. On the other hand, if I combine these queries into one and force both components to fetch everything the other needs, my components become coupled and I may be fetching unnecessary data. I may even have to move the query to a higher level component to guarantee it only happens once. At least on the client, it starts to look like an RPC API where I have one query to fetch each kind of entity and it always fetches everything. I don't see any alternative, but this seems to go against the best practice of making components directly query only for what they need, and we keep running into this problem when we follow that advice. Is there a better philosophy for organizing our queries, components, and data to use the cache and query efficiently without excessive coupling between components?
Post Details
- Posted
- 1 year ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/graphql/com...