You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(This also applies elsewhere to useTable and other hooks with a queryOptions property)
The problem with the former is they are inconsistent with how ReactQuery defines query types.
For example, if I implement queryOptions.queryFn, It won't accept an API that returns type TQueryFnData, insisting that it's wrapped in a { data: TQueryFnData } container. However, in ReactQuery, you just return TQueryFnData from queryFn and ReactQuery itself owns the metadata/lifecycle container, wrapping the returned value in a QueryObserverBaseResult which contains a { data: TQueryFnData } property.
As a consequence, the result object is doubly wrapped: { data: { data: TQueryFnData }}!
I can work around this by wrapping the response in a redundant GetOneResponse, but this should not be necessary. It would be better if the double wrapping were removed.
Steps To Reproduce
Implement queryOptions.queryFn using options that work in a plain useQuery invocation
Expected behavior
Use of ReactQuery should be a thin wrapper that works along with existing knowledge of the ReactQuery APIs
Packages
@refinedev/core
Additional Context
No response
The text was updated successfully, but these errors were encountered:
Hey @davidgoli thanks for taking time to create issue. GetOneResponse is not redundant, it's correct. However, I understand that having double data data may be confusing. This is something we are improving and will remove in the next major version.
Describe the bug
Look at the types at https://github.com/refinedev/refine/blob/0842b702dad2c95966b2a2b49da0a66527bcbea3/packages/core/src/hooks/show/types.ts#L54C1-L58
They should be:
(This also applies elsewhere to
useTable
and other hooks with aqueryOptions
property)The problem with the former is they are inconsistent with how ReactQuery defines query types.
For example, if I implement
queryOptions.queryFn
, It won't accept an API that returns typeTQueryFnData
, insisting that it's wrapped in a{ data: TQueryFnData }
container. However, in ReactQuery, you just returnTQueryFnData
fromqueryFn
and ReactQuery itself owns the metadata/lifecycle container, wrapping the returned value in aQueryObserverBaseResult
which contains a{ data: TQueryFnData }
property.As a consequence, the result object is doubly wrapped:
{ data: { data: TQueryFnData }}
!I can work around this by wrapping the response in a redundant
GetOneResponse
, but this should not be necessary. It would be better if the double wrapping were removed.Steps To Reproduce
Implement
queryOptions.queryFn
using options that work in a plainuseQuery
invocationExpected behavior
Use of ReactQuery should be a thin wrapper that works along with existing knowledge of the ReactQuery APIs
Packages
@refinedev/core
Additional Context
No response
The text was updated successfully, but these errors were encountered: