Gws
A WebSocket client and server for GraphQL
Install / Use
/learn @Zaba505/GwsREADME
gws
A WebSocket client and server for GraphQL.
gws implements Apollos' "GraphQL over WebSocket" protocol,
which can be found in PROTOCOL.md. It provides an RPC-like API for both
client and server usage.
Getting Started
gws provides both a client and server implementation for the
"GraphQL over Websocket" protocol.
Client
To create a client, you must first dial the server like:
conn, err := gws.Dial(context.TODO(), "ws://example.com")
// Don't forget to handle the error
gws.Dial will return high-level abstraction around the
underlying connection. This is very similar to gRPCs'
behaviour. After dialing the server, now simply wrap the
return conn and begin performing queries, like:
client := gws.NewClient(conn)
resp, err := client.Query(context.TODO(), &gws.Request{Query: "{ hello { world } }"})
// Don't forget to handle the error
var data struct{
Hello struct{
World string
}
}
err = json.Unmarshal(resp.Data, &data)
Server
The server implementation provided isn't actually a standalone
server but instead just a specially configured http.Handler.
This is because the underlying protocol is simply WebSocket,
which runs on top of HTTP. Creating a bare bones handler is
as simple as the following:
msgHandler := func(s *Stream, req *Request) error {
// Handle request
return nil
}
http.ListenAndServe(":8080", gws.NewHandler(gws.HandlerFunc(msgHandler)))
Related Skills
node-connect
349.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
349.2kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
109.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
