Skip to main content
VentStream’s real-time gateways turn NATS events into typed GraphQL subscriptions. This demo starts NATS and the engine in 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

This starts NATS (JetStream) and the engine in 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 (▶):
It stays open, waiting for events. (Browse the Docs panel on the right to see orderStatusChanged, the raw orderEvents, and the generic events(subject:).)

3. Publish an event

In a second terminal, publish one event through the bundled nats-box CLI helper (the nats server image has no client). The subject ends with the orderId, and id must be a valid ULID:
GraphiQL updates instantly:
The result field names differ from the payload because the SDL maps them with @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):
GraphiQL receives one result per second, with 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.

5. Teardown