graphql-ruby icon indicating copy to clipboard operation
graphql-ruby copied to clipboard

JavaScript client should use strong typing for `onError` argument

Open jscheid opened this issue 1 year ago • 2 comments

Describe the bug

The typings don't currently specify what to expect from onError: https://github.com/rmosolgo/graphql-ruby/blob/35230d37fe0ec3c04af82eb3b1597631758d3fe3/javascript_client/src/subscriptions/createAblyHandler.ts#L12

For Ably it's de-facto an array of objects: https://github.com/rmosolgo/graphql-ruby/blob/35230d37fe0ec3c04af82eb3b1597631758d3fe3/javascript_client/src/subscriptions/createAblyHandler.ts#L56-L57

It would probably be better for the array to be wrapped in an Error instance, but even if you prefer to leave things as they are, it would be great to have stronger typings here so that implementing robust error handling code doesn't require being prepared for any kind of object.

Versions

graphql-ruby-client version: 1.13.0

jscheid avatar Feb 08 '24 15:02 jscheid

Hey, thanks for the suggestion! My first inclination would be to keep things as they are, for compatibility's sake, but do you think there'd be a way to change it without breaking existing client code?

rmosolgo avatar Feb 08 '24 15:02 rmosolgo

Not really, it would be a breaking change. But making the type declaration match the data shouldn't be causing much problems, and worst case at compile time.

jscheid avatar Feb 08 '24 18:02 jscheid