class
GraphQL::Transport::WebSocket
- GraphQL::Transport::WebSocket
- Reference
- Object
Overview
Serves a schema over a WebSocket with the graphql-transport-ws
protocol used by graphql-ws, Apollo Client, urql and Relay. Not
required by require "graphql"; load it with
require "graphql/transport/ws".
Hand each accepted socket to a new instance. The block builds the
GraphQL::Context for every operation on the connection:
handler = HTTP::WebSocketHandler.new([GraphQL::Transport::WebSocket::PROTOCOL]) do |socket, http|
GraphQL::Transport::WebSocket.new(schema, socket) { MyContext.new(http.request) }
end
Subscriptions stream until the client sends complete or disconnects.
Queries and mutations sent over the socket are executed once and
answered with next and complete.
Defined in:
graphql/transport/ws.crConstant Summary
-
PROTOCOL =
"graphql-transport-ws"
Constructors
- .new(schema : GraphQL::Schema, socket : HTTP::WebSocket, &context : -> GraphQL::Context)
- .new(schema : GraphQL::Schema, socket : HTTP::WebSocket)