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
Currently useSuspenseQuery sets the returned data property to type TData (a generic). This works well with the default behavior since the hook will throw errors when encountered.
There are however a couple cases that will cause data to remain undefined.
Setting errorPolicy to anything other than none (the default). If an error is encountered with all or ignore, the error is not thrown and is expected to be handled locally, but data might not be set.
Setting skip to true (Support skip in useSuspenseQuery #10532). Once this is supported, skip will not load any data, so data is expected to be undefined until skip is false.
Additionally, setting returnPartialData may result in some of missing data. In this case, we should set data to DeepPartial<TData> (note DeepPartial is not a part of TypeScript: we'll need a helper) to better communicate that the data type might not contain all the required values.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For general questions, we recommend using StackOverflow or our discord server.
Currently
useSuspenseQuery
sets the returneddata
property to typeTData
(a generic). This works well with the default behavior since the hook will throw errors when encountered.There are however a couple cases that will cause
data
to remainundefined
.errorPolicy
to anything other thannone
(the default). If an error is encountered withall
orignore
, the error is not thrown and is expected to be handled locally, butdata
might not be set.skip
totrue
(Supportskip
inuseSuspenseQuery
#10532). Once this is supported,skip
will not load any data, sodata
is expected to beundefined
untilskip
isfalse
.Additionally, setting
returnPartialData
may result in some of missing data. In this case, we should setdata
toDeepPartial<TData>
(noteDeepPartial
is not a part of TypeScript: we'll need a helper) to better communicate that thedata
type might not contain all the required values.In short, our types should reflect the following:
errorPolicy: 'none'
->data: TData
errorPolicy: 'ignore'
->data: TData | undefined
errorPolicy: 'all'
->data: TData | undefined
skip: false
->data: TData
skip: true
->data: TData | undefined
returnPartialData: true
->data: DeepPartial<TData>
returnPartialData: false
->data: TData
The text was updated successfully, but these errors were encountered: