0
0
GraphQLquery~10 mins

Why testing validates schema behavior in GraphQL - Test Your Understanding

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

Complete the code to define a GraphQL query that fetches a user's name.

GraphQL
query GetUserName { user(id: 1) { [1] } }
Drag options to blanks, or click blank then click option'
Aname
Bage
Cemail
Daddress
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a field that does not represent the user's name.
Using a field that does not exist in the schema.
2fill in blank
medium

Complete the code to add a variable for user ID in the query.

GraphQL
query GetUser($id: ID!) { user(id: [1]) { name } }
Drag options to blanks, or click blank then click option'
A$id
B1
CuserId
DID
Attempts:
3 left
💡 Hint
Common Mistakes
Using a literal value instead of the variable.
Using a variable name without the dollar sign.
3fill in blank
hard

Fix the error in the mutation to update a user's email.

GraphQL
mutation UpdateEmail($id: ID!, $email: String!) { updateUser(id: [1], email: $email) { id email } }
Drag options to blanks, or click blank then click option'
Aid
B$id
CuserId
Demail
Attempts:
3 left
💡 Hint
Common Mistakes
Using the field name instead of the variable.
Omitting the dollar sign before the variable.
4fill in blank
hard

Fill both blanks to define a fragment for user details and use it in a query.

GraphQL
fragment UserDetails on User { [1] [2] } query GetUser { user(id: 1) { ...UserDetails } }
Drag options to blanks, or click blank then click option'
Aname
Bemail
Cage
Daddress
Attempts:
3 left
💡 Hint
Common Mistakes
Including fields not present in the User type.
Using fields unrelated to user details.
5fill in blank
hard

Fill all three blanks to write a query with variables and aliasing.

GraphQL
query GetUserInfo($userId: ID!) { userInfo: user(id: [1]) { [2] email: [3] } }
Drag options to blanks, or click blank then click option'
A$userId
Bname
CemailAddress
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using literal values instead of variables.
Confusing alias and field names.
Omitting the dollar sign for variables.