refetch() data not working on apollo graphql

Viewed 650

I have a react component that fetches data from Subgraph using Apollo Graphql. The query takes walletAddress as a variables and needs to refetch new data every time walletAddress changes.

This is my current approach. When walletAddress changes, the useEffect hook is properly activated and refetch() is called. But the data never loads and loading is stuck as true.

When I check the network requests, the refetch() call is never made on the backend. Any tips on how to get this refetch() call to work would be greatly appreciated!

const BidsTable = ({walletAddress}) => {
 
  const {data, loading, refetch} = useQuery(GET_BIDS, {
    variables: {
      addr: walletAddress,
    }  
  });

  useEffect(() => {
    refetch();
  }, [walletAddress]);

return (
    ...
)


}
0 Answers
Related