openapi-typescript
openapi-typescript copied to clipboard
openapi-react-query
Changes
This Pull-request brings a new package openapi-tanstack-query
that combines the power of openapi-fetch
and @tanstack/react-query
together.
Here is a simple example:
import createClient from 'openapi-fetch';
import createQueryClient from 'openapi-tanstack-query';
const client = createClient<paths>();
const $api = createQueryClient(client);
const Component = () => {
const { data, error, isLoading } = $api.useQuery('get', '/users');
if (isLoading || !data) return "Loading...";
return data.map((user) => <div key={user.id}>{user.name}</div>);
}
How to Review
How can a reviewer review your changes? What should be kept in mind for this review? WIP
Checklist
- [x] Handles
useQuery
- [x] Handles
useMutation
- [x] Handles
useSuspenseQuery
- [x] Unit tests
- [x]
docs/
updated (if necessary)