-
-
Notifications
You must be signed in to change notification settings - Fork 566
Closed
Labels
PRs welcomePRs are welcome to solve this issue!PRs are welcome to solve this issue!bugSomething isn't workingSomething isn't workinggood first issueStraightforward problem, solvable for first-time contributors without deep knowledge of the projectStraightforward problem, solvable for first-time contributors without deep knowledge of the projectopenapi-react-queryRelevant to openapi-react-queryRelevant to openapi-react-query
Description
Mind: This is a bug in openapi-react-query. There is no template for opening Bugs for the openapi-react-query package yet.
Description
The select
transformer in the queryOptions
of the useQuery method expects a value of type data
as return value. The value should be transformable to an arbitrary value (and be inherited correctly). Example:
Cool:
$api.useQuery('get', '/pets/person', {},
{
select: (data) => data,
}
);
Not cool:
$api.useQuery('get', '/pets/person', {},
{
select: (data) => data.age, // or any other value
}
);
Reproduction
See the implementation at the bottom of fetchClient.ts
in this Stackblitz.
Expected result
Arbitrary return values in the select
method do not throw type errors. Furthermore, data
should infer the type of the returned value of the select
method (if set):
const { data } = $api.useQuery('get', '/pets/person', {},
{
select: (data) => data.age, // this shouldn't throw any type errors
}
);
const str: number | undefined = data; // this shouldn't throw any type errors either as date.age is of type number and optional.
drwpow, jcwillox, yoshi2no and guillaumeLamanda
Metadata
Metadata
Assignees
Labels
PRs welcomePRs are welcome to solve this issue!PRs are welcome to solve this issue!bugSomething isn't workingSomething isn't workinggood first issueStraightforward problem, solvable for first-time contributors without deep knowledge of the projectStraightforward problem, solvable for first-time contributors without deep knowledge of the projectopenapi-react-queryRelevant to openapi-react-queryRelevant to openapi-react-query