hey-api / openapi-ts

🚀 The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more. Support: @mrlubos
https://heyapi.dev
Other
1.39k stars 107 forks source link

Add abort signal to tanstack query queryFn #1189

Closed amarant closed 4 weeks ago

amarant commented 4 weeks ago

Description

Tanstack query can abort the fetch, but it needs to pass the AbortSignal signal prop to the axios or fetch client.

https://tanstack.com/query/latest/docs/framework/react/guides/query-cancellation#query-cancellation

It would be great to add this functionality.

mrlubos commented 4 weeks ago

Hey @amarant, are you asking for this?

import axios from 'axios'

const query = useQuery({
  queryKey: ['todos'],
  queryFn: ({ signal }) =>
    axios.get('/todos', {
      // Pass the signal to `axios`
      signal,
    }),
})
amarant commented 4 weeks ago

exactly

mrlubos commented 4 weeks ago

Say no more ✅