This example demonstrates a basic subscription operation in Apollo Server. See the docs on subscriptions
The example server exposes one subscription (numberIncremented
) that returns an integer that's incremented on the server every second.
After you start up this server, you can test out running a subscription with the Apollo Studio Explorer by following the link from http://localhost:4000/graphql to the Apollo Sandbox. You might need to edit the Apollo Sandbox connection settings to select the graphql-ws
subscriptions implementation. You'll see the subscription's value update every second.
subscription IncrementingNumber {
numberIncremented
}
npm install
npm start