openapi-typescript icon indicating copy to clipboard operation
openapi-typescript copied to clipboard

openapi-react-query

Open kerwanp opened this issue 8 months ago • 18 comments

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)

kerwanp avatar Jun 21 '24 11:06 kerwanp