Hi I am working with a graphql API and I need to automatically re fetch data after an interval(eg. 3 second). I am using reactQuery and tried some hacks like setInterval but its not working fine.
const { data, isLoading } = useQuery(['get_trnx_logs', quoteTokenAddress], () => {
return bitqueryService.getTokenPairTranxLogs(quoteTokenAddress)
})
const feedData = data?.ethereum.dexTrades
? settingTranxLogData(quoteTokenAddress, data.ethereum.dexTrades)
: []
Please help me with this, Or is there a way with Ajax to that also?
react-query supports a refetchInterval option for that:
useQuery(key, fn, { refetchInterval: 5000 })
this refetches every 5 seconds.