Search code examples
react-nativegraphqlapollo

How to execute same query again in Apollo Client


I have a query like this.

 const { loading, error, data } = useQuery(ME,{
        onCompleted: data => {
          console.log(data)
        }
      })

After executing this query, I can not execute this query again. How I can execute same query twice?


Solution

  • Turns out default fetchPolicy is "cache-first". I need to turn off like this.

    const { loading, error, data } = useQuery(ME,{
        onCompleted: data => {
          console.log(data)
        },
        fetchPolicy: 'no-cache'
      })