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' → data becomes undefined, errors in result.error
errorPolicy: 'all' → data preserved, errors in result.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
error callback?
- Should
errorPolicy: 'none' route GraphQL errors to the error callback (as it seemed to in v3)?
Environment
@apollo/client: 4.x
- Multipart HTTP subscriptions
Description
After upgrading to Apollo Client 4, GraphQL errors in subscription responses never trigger the
errorcallback. They always arrive in thenextcallback viaresult.error, regardless oferrorPolicy.The only difference between error policies:
errorPolicy: 'none'→databecomesundefined, errors inresult.errorerrorPolicy: 'all'→datapreserved, errors inresult.errorServer response payload
{ "payload": { "data": { "mySubscription": { "id": "123", "status": "active" } }, "errors": [ { "message": "Resource not found", "path": ["mySubscription", "relatedEntity"], "extensions": { "code": "NOT_FOUND" } } ] } }Client code
Questions:
errorcallback?errorPolicy: 'none'route GraphQL errors to theerrorcallback (as it seemed to in v3)?Environment
@apollo/client: 4.x