GithubHelp home page GithubHelp logo

Comments (4)

zenflow avatar zenflow commented on May 19, 2024

I was thinking about taking a try at fixing this sometime in the next few days, although I have no typescript experience (yet).. Somebody may need to help with or correct that aspect of my changes to get it merged, but it would at least get the ball rolling.

The changes I would like to make:

  • Don't ever copy data from the __queryCache onto root type model instances. Only copy data from query results [onto root type model instances] when those results are from network (not cache).
  • Filter/remove [now-] unused data from __queryCache, so root type objects in query results [in __queryCache] have no properties except __typename and id (the two that are needed to find the object among our cached model instances).

@mweststrate @chrisdrackett @dpnolte @mattiasewers Please let me know if you disagree with that change in principle, or if for any other reason I shouldn't bother working on this. Thanks for your time :)

from mst-gql.

chrisdrackett avatar chrisdrackett commented on May 19, 2024

@zenflow I haven't had a chance to look at this issue yet. I might have some time later this week to download the code and dig through.

from mst-gql.

chrisdrackett avatar chrisdrackett commented on May 19, 2024

@zenflow I think this issue is worth looking at for sure. This is one of the first things I ran into when using mst-gql as well. In our projects we "get around" it by never using data from useQuery in any of our components and instead only ever referencing the store directly.

First off IMO the following suggestions:

  • Don't ever copy data from the __queryCache onto root type model instances. Only copy data from query results [onto root type model instances] when those results are from network (not cache).
  • Filter/remove [now-] unused data from __queryCache, so root type objects in query results [in __queryCache] have no properties except __typename and id (the two that are needed to find the object among our cached model instances).

are solid and I think we should do them.

It seems to me that if you are using GraphQL is a more read-only way the current behavior of the cache is good and does not have many problems. However, if you are often mutating data this pattern breaks down as the cache is very often going to be out of date in one way or another. The above starts to address this.

If you want to get a PR going I'm more than happy to look at it!

from mst-gql.

zenflow avatar zenflow commented on May 19, 2024

Looks like my second suggested change ("Filter/remove [now-] unused data from __queryCache...") did not take into account the raw: true option for queries. These queries currently depend on having fully populated objects in __queryCache . I bring up this problem and a proposed solution in PR #97.

from mst-gql.

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.