Skip to content

Commit

Permalink
Update example/chat/readme.md
Browse files Browse the repository at this point in the history
Co-authored-by: Jared Forsyth <jabapyth@gmail.com>
Signed-off-by: Steve Coffman <steve@khanacademy.org>
  • Loading branch information
StevenACoffman and jaredly committed Nov 9, 2021
1 parent 1606046 commit 07191a6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion example/chat/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Then to run the app with the `apollo-link-ws` implementation do
npm run start
```

or to run the app with the `graphql-ws` implementation do
or to run the app with the `graphql-ws` implementation (and the newer `graphql-transport-ws` protocol) do
```bash
npm run start:graphql-transport-ws
```
15 changes: 11 additions & 4 deletions graphql/handler/transport/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,19 @@ func (c *wsConnection) subscribe(start time.Time, msg *message) {
go func() {
defer func() {
if r := recover(); r != nil {
userErr := rc.Recover(ctx, r)
c.sendError(msg.id, &gqlerror.Error{Message: userErr.Error()})
err := rc.Recover(ctx, r)
var gqlerr *gqlerror.Error
if !errors.As(err, &gqlerr) {
gqlerr = &gqlerror.Error{}
if err != nil {
gqlerr.Message = err.Error()
}
}
c.sendError(msg.id, gqlerr)
}
c.complete(message.ID)
c.complete(msg.id)
c.mu.Lock()
delete(c.active, message.ID)
delete(c.active, msg.id)
c.mu.Unlock()
cancel()
}()
Expand Down
3 changes: 2 additions & 1 deletion graphql/handler/transport/websocket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ func TestWebsocketGraphqltransportwsSubprotocol(t *testing.T) {
}

func wsConnect(url string) *websocket.Conn {

return wsConnectWithSubprocotol(url, "")
}

Expand All @@ -327,7 +328,7 @@ func wsConnectWithSubprocotol(url, subprocotol string) *websocket.Conn {
h.Add("Sec-WebSocket-Protocol", subprocotol)
}

c, resp, err := websocket.DefaultDialer.Dial(strings.Replace(url, "http://", "ws://", -1), h)
c, resp, err := websocket.DefaultDialer.Dial(strings.ReplaceAll(url, "http://", "ws://"), h)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 07191a6

Please sign in to comment.