urql-graphql / urql

The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
https://urql.dev/goto/docs
MIT License
8.57k stars 444 forks source link

feat(core): Handle GraphQLError[] value in error observer callback of subscriptionExchange #3346

Closed kitten closed 1 year ago

kitten commented 1 year ago

Resolves #3345

Summary

Note: I'd prefer not to ship this and there's an ongoing discussion in #3345, that requires confirmation before this change is made. This is simply already submitted for reference for the discussion.

The reason why I'd prefer not to ship this is that we're basically forced to simply check using Array.isArray for an array value on the error callback and then circumvent issuing a network error and instead issue a result — potentially merging prior results — when GraphQLError[] is passed as a value.

I find this extremely odd precisely because using next + complete feels much more natural here. GraphQLError[], as part of the ExecutionResult's errors, is a defined shape of a result and can be accepted at any time. Receiving it in errors basically forces a new code path for functionality that already exists.

The addition here basically just uses the next case for error.

Set of changes