Introduction
Subscriptions let your app get updates instantly when data changes. This means you see new info right away without asking again.
Subscriptions let your app get updates instantly when data changes. This means you see new info right away without asking again.
subscription SubscriptionName {
eventName {
field1
field2
}
}subscription NewMessages {
messageAdded {
id
text
sender
}
}subscription StockPriceUpdates {
stockPriceChanged {
symbol
price
}
}This subscription listens for new comments added to a post. When a comment is added, it sends the id, content, and author immediately.
subscription OnNewComment {
commentAdded {
id
content
author
}
}Subscriptions require a WebSocket or similar connection to keep data flowing.
They are great for live updates but can use more resources than regular queries.
Subscriptions let apps get data updates instantly without asking repeatedly.
They keep a connection open to push new data as it happens.
Use them when you want real-time updates like chats, notifications, or live stats.
newMessage?subscription to define real-time data streams.subscription { newMessage { id content } }.subscription { newNotification { id message } }id and message fields.subscription newMessage { id content }id and content, causing a syntax error.Pass the test and this pattern moves unknown