Protocols
Protocol Directive
protocol = graphql
If protocol is omitted, the request is ordinary HTTP.
Hen currently supports:
- HTTP by default
protocol = graphqlprotocol = sseprotocol = ws
GraphQL
protocol = graphql
POST https://example.com/graphql
operation = GetUser
variables = {"id":"123"}
~~~graphql
query GetUser($id: ID!) {
user(id: $id) {
id
}
}
~~~
- GraphQL requests currently require
POST graphql.data...andgraphql.errors...alias JSON body paths- callback environments receive
GRAPHQL_DOCUMENT,GRAPHQL_OPERATION, andGRAPHQL_VARIABLES
SSE
protocol = sse
session = prices
receive
within = 5s
- SSE opening requests currently require
GET receiveconsumes the next queued event for the named sessionsse.eventandsse.idare available for captures and assertions- when the event payload is valid JSON, ordinary
body...paths work for assertions and captures - if the opening step omits
Accept, Hen sendsAccept: text/event-streamautomatically
WebSocket
protocol = ws
session = chat
within = 2s
~~~json
{"type":"hello"}
~~~
- WebSocket opening requests currently require
GET - a body block implies a send step
- body plus
withinturns a step into an exchange step ws.kindexposes the observed frame type
For protocol = ws, plain ~~~ or ~~~text sends text, while ~~~json or
~~~application/json sends JSON.