reactjs – How data.refetch() function from react-apollo works

reactjs – How data.refetch() function from react-apollo works

It seem that refetch function is not meant to refetch data with different variables set (see this discussion).

I finally and successfully solved my issue with the help from this article

you can do it by adding refetch in useQuery

 const {loading, data, error,refetch} = useQuery(GET_ALL_PROJECTS,
        {
            variables: {id: JSON.parse(localStorage.getItem(user)).id}
        });

then call function refetch()

 const saveChange = input => {
               refetch();

    };

OR

const saveChange = input => {
        setIsOpen(false);
        addProject({

            variables: {
                createBacklogInput: {
                    backlogTitle: backlogInput,
                   project:id
                }
            }
        }).then(refetch);

reactjs – How data.refetch() function from react-apollo works

Leave a Reply

Your email address will not be published.