0
0
GraphQLquery~10 mins

Query variables 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 declare a variable for a GraphQL query.

GraphQL
query GetUser($id: [1]) { user(id: $id) { name } }
Drag options to blanks, or click blank then click option'
ABoolean
BString
CInt
DFloat
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number type like Int when the ID is a string.
Forgetting the dollar sign before the variable name.
2fill in blank
medium

Complete the code to pass a variable in the GraphQL query arguments.

GraphQL
query GetPost($postId: ID!) { post(id: [1]) { title content } }
Drag options to blanks, or click blank then click option'
ApostId
BpostID
Cid
D$postId
Attempts:
3 left
💡 Hint
Common Mistakes
Using the variable name without the $ prefix.
Using a different variable name than declared.
3fill in blank
hard

Fix the error in the variable declaration for a required integer variable.

GraphQL
query GetComments($limit: [1]) { comments(limit: $limit) { text } }
Drag options to blanks, or click blank then click option'
AInt!
BInt
CString!
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the exclamation mark for a required variable.
Using the wrong type like String for a number.
4fill in blank
hard

Fill both blanks to declare and use a Boolean variable in a query.

GraphQL
query GetTasks($completed: [1]) { tasks(completed: [2]) { id title } }
Drag options to blanks, or click blank then click option'
ABoolean!
BBoolean
C$completed
Dcompleted
Attempts:
3 left
💡 Hint
Common Mistakes
Using the variable name without $ inside the query.
Declaring the variable without the exclamation mark when it is required.
5fill in blank
hard

Fill all three blanks to declare a variable, use it in the query, and specify its type as a list of IDs.

GraphQL
query GetUsers($ids: [1]) { users([3]: [2]) { name email } }
Drag options to blanks, or click blank then click option'
A[ID!]
B$ids
Cids
DID
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to use square brackets for list types.
Using the variable name without $ inside the query.
Mixing up the argument name and variable name.