useSuspenseQuery
should always throw network errors regardless of error policy
#10384
Labels
useSuspenseQuery
should always throw network errors regardless of error policy
#10384
While implementing the error policy behavior with
useSuspenseQuery
, I misunderstood howignore
is supposed to work when a network error occurs. Per the error policy docs:The key here is that GraphQL errors are ignored, not network errors.
To compare with
useQuery
, when a network error occurs, theonError
callback is called with the network error and theerror
property is populated. I assume because there is no possibility that partial data will ever be returned. See this diff that demonstrates this behavior.I think
useSuspenseQuery
should work similarly touseQuery
. The outstanding question is whether we shouldthrow
(which would act more likeerrorPolicy: "none"
), or whether we populate theerror
property (which would act more likeerrorPolicy: "all"
).In fact, this question could expand to
errorPolicy: "all"
as well. ShoulduseSuspenseQuery
alwaysthrow
when a network error occurs, regardless of the error policy? This aligns with the behavior ofuseQuery
where theonError
callback is always called with network errors, regardless of theerrorPolicy
. After having read the docs a bit closer, it seems theerrorPolicy
is really meant for altering the behavior when GraphQL errors are encountered and it doesn't really apply to network errors. I'm inclined to say that network errors should always be thrown since these are typically unexpected errors outside of GraphQL.How to reproduce the issue:
This is an intentional design decision. You can see this demonstrated in the
useSuspenseQuery
test suite.Versions
v3.8.0-alpha.x
The text was updated successfully, but these errors were encountered: