Giter Site home page Giter Site logo

Comments (3)

jamesreggio avatar jamesreggio commented on July 30, 2024 1

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.

anthonychung14 avatar anthonychung14 commented on July 30, 2024

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.

jamesreggio avatar jamesreggio commented on July 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.