Giter VIP home page Giter VIP logo

Comments (7)

jamiemetca avatar jamiemetca commented on June 23, 2024 1

I had the same issue and fixed it using proxy.modify.

      proxy.modify({
        fields: {
          getPosts( existingPostRefs, { readField }) {
            return existingPostRefs.filter( postRef => postId !== readField("id", postRef ));
          }
        }
      })

from classsed-graphql-mern-apollo.

ArielPenna avatar ArielPenna commented on June 23, 2024

the console.log brings the getposts aray perfectly, but the console throw a "can't read property getPosts of undefined"
error

from classsed-graphql-mern-apollo.

mariusflorescu avatar mariusflorescu commented on June 23, 2024

Hello @ArielPenna , this might solve your issue:

You should add a poll interval to your useQuery in your Homepage.js, like this:

const {loading, data={}} = useQuery(FETCH_POSTS_QUERY,{
    pollInterval: 500,
  });

from classsed-graphql-mern-apollo.

ArielPenna avatar ArielPenna commented on June 23, 2024

Hi, @mariusflorescu thats not working either

from classsed-graphql-mern-apollo.

mariusflorescu avatar mariusflorescu commented on June 23, 2024

Agh sorry, I didn't read the issue carefully enough.
Try to apply the previous changes + the pollInterval
See the edit.

from classsed-graphql-mern-apollo.

ArielPenna avatar ArielPenna commented on June 23, 2024

@mariusflorescu thanks, but it didn't solve py issue, the problem is tha when i press de delete button, it actually delet the post but no reload (when in home) or redirect to home (when in singlepost)

from classsed-graphql-mern-apollo.

Cornstar23 avatar Cornstar23 commented on June 23, 2024

Instead of modifying data.getPosts and passing it into proxy.writeQuery, just set a data element directly:

proxy.writeQuery({
  query: FETCH_POSTS_QUERY,
  data: { getPosts: data.getPosts.filter((p) => p.id !== postId) },
})

from classsed-graphql-mern-apollo.

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.