Comments (3)
Hi @anthonychung14 — welcome to the project.
I've implemented 95% of the support needed for inline fragments over in #183. If you'd like to begin using it today, I'd suggest you incorporate my branch into a private fork.
(The comment thread on that PR outlines the remaining work needed to get support to 100%, and it's not trivial — it involves having the entire schema available on the client to understand which fragment was matched. This remaining work is mostly in the realm of validation, so it doesn't need to be finished to begin using the branch today.)
from apollo-cache-hermes.
I'd be interested in helping with this, though I'm just now getting onboarded with the source code. Our team would benefit greatly from incorporating the improvements you've made with the apollo cache.
Here's how I understand the lib + parsing queries with InlineFragment
-
Currently, reading an inline fragment would result in a "failed lookup" since it doesn't know that the fragment needs to be rebuilt (later on?). I'm assuming this is why you mentioned flagging them as union fields.
-
It seems like here detects and flattens fragments into the nodeMap. This implies to me that fragments are already (in a sense) being "walked" and they only need to be flagged as unions.
https://github.com/convoyinc/apollo-cache-hermes/blob/master/src/ParsedQueryNode.ts#L148 -
So, would we then want to adjust how
_mergeNodes
works to complete this flagging?
from apollo-cache-hermes.
We've merged support for inline fragments in #183. In the process of implementing it, it became clear that the 'hard' part of this is handling multiple fragments for different types on a given object. This is a common scenario when querying a union type (because you'll likely have one fragment for potential type in the union), but it also crops up when querying object interfaces.
The problem is that without the client being aware of the schema, it doesn't know which type fragments actually matched the object on the server; consequently, it doesn't know which keys to write into the cache, and which to ignore.
@nevir illustrated this problem in #183 (review). Generally, this problem is benign, because it only results in extra nullified keys in the cached object. However, as illustrated in #183 (comment), it can become a little more risky when an object changes types, because you can end up with residual key/value pairs from the prior type fragments.
In the end, this will require something akin to IntrospectionFragmentMatcher
from apollo-cache-inmemory
to solve. Would be happy to guide anybody who would like to take on this work.
from apollo-cache-hermes.
Related Issues (20)
- An in-range update of apollo-cache is breaking the build 🚨 HOT 4
- Switch from chai to jasmine expectations
- Stale data passed to Query prop after writeFragment operation HOT 1
- Cache returns incorrect data when using aliases on different fields with the same name HOT 4
- Verify that migrated reference field correctly garbage collects `outbound` and `inbound` references
- Continuous crashes on React Native Android HOT 11
- Add better description of what a normalized graph cache is HOT 1
- Concurrent access from multiple instances HOT 1
- Cannot execute consecutive queries that would return the same data HOT 4
- Does not work with create-react-app with Typescript
- writeFragment blows away entity's __typename HOT 10
- RangeError: Maximum call stack size exceeded with a slightly complex query
- Adding more descriptive logging for InvalidPayloadError HOT 3
- Implement or document dataIdFromObject HOT 4
- Support freezeResults? HOT 2
- Much bigger than apollo-cache-inmemory HOT 1
- missing peer dependency on graphql
- bug: `GraphSnapshot` is not exported (but should be)
- 'useQuery' never returns data for entries written to the cache with 'writeFragment'
- Sync cache across tabs? HOT 1
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 apollo-cache-hermes.