From 1741410f7b30c9b738e60b48b0842b834782cea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E8=BF=9E=E4=BA=91?= <562050688@qq.com> Date: Thu, 20 Apr 2023 12:26:13 +0800 Subject: [PATCH] fix: OnError message is not called in subscriptions-transport-ws (#88) --- subscriptions_transport_ws.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/subscriptions_transport_ws.go b/subscriptions_transport_ws.go index 9caca07..c7a0431 100644 --- a/subscriptions_transport_ws.go +++ b/subscriptions_transport_ws.go @@ -114,6 +114,16 @@ func (stw *subscriptionsTransportWS) OnMessage(ctx *SubscriptionContext, subscri switch message.Type { case GQLError: ctx.Log(message, "server", GQLError) + var errs Errors + jsonErr := json.Unmarshal(message.Payload, &errs) + if jsonErr != nil { + subscription.handler(nil, fmt.Errorf("%s", string(message.Payload))) + return nil + } + if len(errs) > 0 { + subscription.handler(nil, errs) + return nil + } case GQLData: ctx.Log(message, "server", GQLData) var out struct {