Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to subscribe to new messages with a filter on the channel ID.
GraphQL
subscription OnMessageAdded {
messageAdded(channelId: [1]) {
id
content
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number without quotes for channelId.
Using a variable name instead of a string literal.
✗ Incorrect
The channelId argument must be a string, so it needs quotes around the ID value.
2fill in blank
mediumComplete the filter argument to subscribe only to messages where the author is 'alice'.
GraphQL
subscription OnMessageAdded {
messageAdded(filter: { author: { [1]: "alice" } }) {
id
content
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'neq' instead of 'eq' causes filtering for authors not equal to 'alice'.
Using 'contains' or 'in' when exact match is needed.
✗ Incorrect
The 'eq' operator filters messages where author equals 'alice'.
3fill in blank
hardFix the error in the subscription filter to only get messages with content length greater than 100.
GraphQL
subscription OnMessageAdded {
messageAdded(filter: { content: { length: { [1]: 100 } } }) {
id
content
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'lt' or 'lte' filters for smaller content lengths.
Using 'eq' filters only exact length 100, not greater.
✗ Incorrect
The 'gt' operator means 'greater than', which filters content length over 100.
4fill in blank
hardFill both blanks to subscribe to messages where the author is 'bob' and the content contains 'hello'.
GraphQL
subscription OnMessageAdded {
messageAdded(filter: { author: { [1]: "bob" }, content: { [2]: "hello" } }) {
id
content
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'neq' for author filters out 'bob' messages.
Using 'eq' for content requires exact match, not substring.
✗ Incorrect
Use 'eq' to match author exactly and 'contains' to check if content includes 'hello'.
5fill in blank
hardFill all three blanks to subscribe to messages where the channelId is 'general', the author is not 'eve', and the content length is less than 50.
GraphQL
subscription OnMessageAdded {
messageAdded(filter: { channelId: [1], author: { [2]: "eve" }, content: { length: { [3]: 50 } } }) {
id
content
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the channelId string.
Using 'eq' instead of 'neq' to exclude author.
Using 'gt' instead of 'lt' for content length.
✗ Incorrect
ChannelId must be the string 'general', author filter uses 'neq' to exclude 'eve', and content length uses 'lt' for less than 50.