0
0
GraphQLquery~10 mins

Subscription filtering in GraphQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
AchannelId
B123
C"123"
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number without quotes for channelId.
Using a variable name instead of a string literal.
2fill in blank
medium

Complete 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'
Aeq
Bneq
Ccontains
Din
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.
3fill in blank
hard

Fix 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'
Alte
Blt
Ceq
Dgt
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'lt' or 'lte' filters for smaller content lengths.
Using 'eq' filters only exact length 100, not greater.
4fill in blank
hard

Fill 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'
Aeq
Bneq
Ccontains
Din
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'neq' for author filters out 'bob' messages.
Using 'eq' for content requires exact match, not substring.
5fill in blank
hard

Fill 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'
A"general"
Bneq
Clt
Deq
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.