graphqlws
graphqlws copied to clipboard
subscription.SendData does not include errors when sending JSON over websocket
So I have configured a subscription manager, and it is successfully creating subscriptions, but I wanted to validate certain variables that are sent over with the Subscription
when it is created. If they aren't valid, I execute the following code:
data := graphqlws.DataMessagePayload{
Errors: []error{errors.New("subscription failed: invalid.")},
}
sub.SendData(&data)
This is all well and fine, except that the message that is getting written out to the websocket looks like this:
{"id":"dave","type":"data","payload":{"data":null,"errors":[{}]}}
I certainly expected the data key in the payload to be null or empty, but I expect the errors to be written out to the errors
key in the payload JSON instead of being [{}]
. Am I doing something wrong here?
Thanks