Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete button issue #16

Closed
ArielPenna opened this issue Nov 9, 2020 · 7 comments
Closed

Delete button issue #16

ArielPenna opened this issue Nov 9, 2020 · 7 comments

Comments

@ArielPenna
Copy link

image
the delete button does not automatically update the render, I have to reload, and in the single post page i doesn't redirec me to home either.
Any Idea?

@ArielPenna
Copy link
Author

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

@mariusflorescu
Copy link

mariusflorescu commented Nov 15, 2020

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,
  });

@ArielPenna
Copy link
Author

Hi, @mariusflorescu thats not working either

@mariusflorescu
Copy link

mariusflorescu commented Nov 16, 2020

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

@ArielPenna
Copy link
Author

@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)

@jamiemetca
Copy link

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 ));
          }
        }
      })

@Cornstar23
Copy link

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) },
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants