0
0
GraphQLquery~10 mins

Single endpoint architecture 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 define a GraphQL query field named 'user'.

GraphQL
type Query { user(id: ID!): [1] }
Drag options to blanks, or click blank then click option'
ABoolean
BString
CInt
DUser
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a scalar type like String instead of the User type.
Using Boolean or Int which do not represent user objects.
2fill in blank
medium

Complete the code to define a GraphQL mutation field named 'addUser'.

GraphQL
type Mutation { addUser(input: AddUserInput!): [1] }
Drag options to blanks, or click blank then click option'
AUser
BString
CInt
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Returning Boolean instead of the User object.
Returning a scalar type like String or Int.
3fill in blank
hard

Fix the error in the GraphQL schema by completing the type definition for 'Post'.

GraphQL
type Post { id: ID! title: String! author: [1] }
Drag options to blanks, or click blank then click option'
AInt
BString
CUser
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using String or Int instead of the User type for author.
Using Boolean which is not appropriate here.
4fill in blank
hard

Fill both blanks to complete the GraphQL query for fetching posts with their authors.

GraphQL
query { posts { id title author { [1] [2] } } }
Drag options to blanks, or click blank then click option'
Aid
Bname
Cemail
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing email or age which may not be required.
Selecting only one field instead of both.
5fill in blank
hard

Fill all three blanks to complete the GraphQL mutation for updating a user's email.

GraphQL
mutation { updateUser(id: [1], input: { email: [2] }) { [3] } }
Drag options to blanks, or click blank then click option'
A"123"
B"newemail@example.com"
Cemail
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting quotes around string values.
Requesting the id field instead of email in the response.
Using numeric or unquoted values for id or email.