question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

question: access to graphcache directly

See original GitHub issue

we 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:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kittencommented, Jun 11, 2020

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

0reactions
wuweiweiwucommented, May 25, 2020

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 #317

Thanks for the detailed response! much appreciated!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found