Open straygar opened 10 months ago
Hey,👋 thanks for raising this! I'm going to transfer this over to our JS repository for better assistance 🙂.
Hi @straygar thanks for opening this issue. Regarding using TanStack Query with the JS library, have you had a chance to look at the documentation here?
Yup, sure have! The docs say (if I understand correctly) that you should write a react-query wrapper for every API operation, but I wonder if we can provide a generic wrapper, especially given the new magical Data API in Gen2:
const { data, errors } = client.models.Book.list({
filters: ...
});
I assume this should be possible, based on the zod-like data model schema you can now define in your data/resource.ts
file.
Environment information
Description
Orval is a wrapper around Tanstack React Query, auto-generated from an OpenAPI spec.
It would be fantastic and lead to much cleaner React Web & Native code if we could auto-generate hooks to access our data and manage loading, error states, instead of manually having to deal with
useEffect
anduseState
.Here is what it would look like with an Orval-like interface:
Although something like this could also work and would avoid code generation: