-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Description
Description
After upgrading to Apollo Client 4, GraphQL errors in subscription responses never trigger the error callback. They always arrive in the next callback via result.error, regardless of errorPolicy.
The only difference between error policies:
errorPolicy: 'none'→databecomesundefined, errors inresult.errorerrorPolicy: 'all'→datapreserved, errors inresult.error
Server response payload
{
"payload": {
"data": {
"mySubscription": { "id": "123", "status": "active" }
},
"errors": [
{
"message": "Resource not found",
"path": ["mySubscription", "relatedEntity"],
"extensions": { "code": "NOT_FOUND" }
}
]
}
}Client code
client.subscribe({ query: MySubscription }).subscribe({
next: (result) => {
// GraphQL errors always arrive here in result.error
// With 'none': result.data is undefined
// With 'all': result.data is preserved
},
error: (error) => {
// Never called (for GraphQL errors at least....)
},
});Questions:
- Is this the intended behavior for subscriptions in Apollo Client 4?
- What errors are expected to trigger the
errorcallback? - Should
errorPolicy: 'none'route GraphQL errors to theerrorcallback (as it seemed to in v3)?
Environment
@apollo/client: 4.x- Multipart HTTP subscriptions
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels