0
0
GraphQLquery~10 mins

Why securing GraphQL is critical - 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 user data.

GraphQL
query GetUser { user(id: [1]) { name email } }
Drag options to blanks, or click blank then click option'
AuserId
B123
C"123"
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using an unquoted number instead of a string ID.
2fill in blank
medium

Complete the code to add an authorization header to a GraphQL request.

GraphQL
fetch('/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': [1] }, body: JSON.stringify({ query }) })
Drag options to blanks, or click blank then click option'
A"token123"
BBearer token123
C'token123'
D'Bearer token123'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting quotes around the header value.
3fill in blank
hard

Fix the error in the GraphQL schema definition for a secure user type.

GraphQL
type User { id: ID! name: String! email: [1] }
Drag options to blanks, or click blank then click option'
AString
BInt
CBoolean
DFloat
Attempts:
3 left
💡 Hint
Common Mistakes
Using Int or Boolean for email field.
4fill in blank
hard

Fill both blanks to create a GraphQL query that limits data exposure by requesting only id and name.

GraphQL
query GetUsers { users { [1] [2] } }
Drag options to blanks, or click blank then click option'
Aid
Bemail
Cname
Dpassword
Attempts:
3 left
💡 Hint
Common Mistakes
Including sensitive fields like password or email in the query.
5fill in blank
hard

Fill all three blanks to write a GraphQL mutation that updates a user's email securely.

GraphQL
mutation UpdateUserEmail { updateUser(id: [1], email: [2]) { [3] } }
Drag options to blanks, or click blank then click option'
A"123"
B"newemail@example.com"
Cemail
Dpassword
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted values or returning sensitive fields like password.