Query examples for events subscription
You can perform events subscription with subscription operations for the following GraphQL types:
-
Item
-
Job
-
Publishing
For a complete list of available types and operations, refer to the built-in documentation in the GraphQL IDE.
Enable WebSocket on IIS
Graphql subscription requires WebSocket for two ways communication.
To turn on the WebSocket feature in Windows Internet Information Services and authenticate with access token:
-
In the Control Panel, open Windows Features and enable the WebSocket Protocol feature.

-
After the features have been enabled, go to IIS on Windows, then click on the root Site.
-
Under Management, click on Configuration Editor.
-
In the Section dropdown box, type "system.webServer/webSocket", then to the right, click Unlock Section.

-
Add the following in SitecoreCMInstance
web.config: -
Create an access token.
-
Use your access token when creating a WebSocket GraphQL client in NodeJS with graphql-ws to connect to your Authoring endpoint, as in the following example:
Query examples for Item
The following sections contain example queries for events subscription.
On Item Added
You can receive the “on item added” event data with an onItemAdded subscription.
Query
Result
On Job Started
You can receive the “on job started” event data with an onJobStarted subscription.
Query
Result
Publishing Status Updated
You can receive the “publishingStatusUpdated” event data with a publishingStatusUpdated subscription.