Subscription data = event with requested fields [OK]
Hint: Subscription returns data object with event and fields [OK]
Common Mistakes:
Returning id as string instead of number
Missing fields in response
Expecting error when subscription is valid
4. You wrote this subscription:
subscription { newMessage { content sender } }
But your client never receives updates. Which is the most likely cause?
medium
A. The client is using a query instead of a subscription
B. The subscription syntax is invalid
C. The server does not publish events for newMessage
D. The fields content and sender do not exist
Solution
Step 1: Check subscription syntax
The syntax is correct, so syntax errors are unlikely.
Step 2: Consider server event publishing
If the server never sends events for newMessage, the client won't get updates.
Step 3: Verify client usage
The client uses subscription syntax, so it's not using a query.
Step 4: Confirm fields existence
Assuming fields exist, the main issue is missing server events.
Final Answer:
The server does not publish events for newMessage -> Option C
Quick Check:
No server events = no subscription updates [OK]
Hint: Check if server sends events for the subscription [OK]
Common Mistakes:
Assuming syntax error without checking server
Confusing query with subscription on client
Ignoring server-side event publishing
5. You want to create a subscription that only sends updates when a new chat message is sent by user "Alice". Which subscription definition correctly filters messages by sender?
hard
A. subscription { newMessage { content sender } where sender = "Alice" }
B. subscription { newMessage(sender: "Alice") { content sender } }