ws,graphql mode,
then displays the subscription stream in GraphiQL.
The typed subscription fields come from an SDL file
(
demo/realtime/subscriptions.graphql) wired in via VS_GRAPHQL_SCHEMA.
See Real-time subscriptions for how
@vsSubscribe maps a field to a subject.Prerequisites
- Docker + Docker Compose v2
- Free ports:
4041(GraphQL),4222(NATS),4043(health)
1. Start the stack
ws,graphql mode — the
ws role bootstraps the vsws stream, the graphql role serves
subscriptions from it. Confirm it’s up:
2. Subscribe in GraphiQL
Open http://localhost:4041/graphiql — the subscription endpoint and connection params are pre-wired. Run (▶):orderStatusChanged, the raw orderEvents, and the generic
events(subject:).)
3. Publish an event
In a second terminal, publish one event through the bundlednats-box CLI
helper (the nats server image has no client). The subject ends with the
orderId, and id must be a valid ULID:
@source: id ← $event.entityId, status ← $data.status, changedAt ← $event.occurredAt (see subscriptions.graphql and Real-time subscriptions).
4. Optional — stream continuous changing events
To watch the subscription tick live, publish a changing event every second. Leave the GraphiQL subscription running and run this in another terminal (Ctrl-C to stop):
status alternating between
paid and shipped and changedAt advancing. The shell example uses st
because status is read-only in zsh.
Every event needs a fresh, valid ULID for
id and schema_version: 2.
The subject grammar is vs.t.<tenant>.<event>.<id> (id last) — publishing
to …orderStatusChanged.order_1 is what routes it to the
orderId: "order_1" subscription.