question: access to graphcache directly
See original GitHub issuewe have currently implemented a way to getting normalized entities from our graphql queries using a mix or normalizr
and @apollo/client
readFragment
however, we’d like to move to urql
for our graphql client.
One major difference that Ive noticed is that readFragment
is only available within the graphcache resolver and cannot be access directly (ie: inside a component) whereas apollo exposes client.readFragment
directly
Following up on discussions from https://github.com/FormidableLabs/urql/issues/85 and https://github.com/FormidableLabs/urql/issues/317. is there a way to access the cache directly and/or use readFragment
directly?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
question: access to graphcache directly · Issue #829 - GitHub
we have currently implemented a way to getting normalized entities from our graphql queries using a mix or normalizr and @apollo/client ...
Read more >Graphcache | urql Documentation
Graphcache stores data in a normalized data structure. Query, mutation and subscription results may update one another if they share data, and the...
Read more >Display Partial Data From Cache with GraphCache - Egghead.io
Install GraphCache and use the schema awareness feature to return partial data from cache. Resources:
Read more >GraphCache: A Caching System for Graph Queries - CORE
Graph query processing is essential for graph analytics, but can be very time-consuming as it entails the NP-Complete problem of subgraph isomorphism.
Read more >Caching Relational GraphQL Data - Kitten
Apollo and Graphcache on the other hand assume that a type may have ... On a side note, this data structure is directly...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We’ve built-in warnings actually and mechanisms that are very tailored towards a normal query flow, which ensure things like commutative cache updates and consistent cache data towards server data. So to have an escape hatch would not only go against that but would probably require a new API layer and a bunch more code which pushes the bundle size.
We haven’t yet found a lot of use cases that require us to go down this road, especially since GraphQL schemas typically cater for the UI, i.e. direct fragment access should not be necessary if the
Query
has query fields for all individual types.I’ll close this for now if that’s alright 😃 but happy to discuss this more in RFCs
I see! we’ve briefly explored the fragment approach but failed to find a way to elegantly handle recursive graphql types but i think its worth another try. I agree that its an effective pattern that meshes well with component based ui architectures.
that totally makes sense! as the default document cache cannot unlock a first class fragment api
I wonder if its possible to expose the
cache
instance as a property somehow like__dangerousDontUseCacheInstance
im also happy to contribute sometime to further #317Thanks for the detailed response! much appreciated!