0
0
GraphQLquery~10 mins

Why relationships model real data 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 type for a user with an ID field.

GraphQL
type User { id: [1] }
Drag options to blanks, or click blank then click option'
AID!
BString
CInt
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using String instead of ID for unique identifiers.
Omitting the non-nullable exclamation mark.
2fill in blank
medium

Complete the code to add a posts field to the User type representing a list of posts.

GraphQL
type User { posts: [1] }
Drag options to blanks, or click blank then click option'
A[Post!]
BPost
C[Post]
DPost!
Attempts:
3 left
💡 Hint
Common Mistakes
Using a single Post type instead of a list.
Not marking the posts as non-nullable inside the list.
3fill in blank
hard

Fix the error in the Post type by completing the author field to link back to the User type.

GraphQL
type Post { author: [1] }
Drag options to blanks, or click blank then click option'
A[User]
BID
CUser!
DString
Attempts:
3 left
💡 Hint
Common Mistakes
Using a list of users instead of a single user.
Using String or ID instead of User type.
4fill in blank
hard

Fill both blanks to define a Comment type with an author and a post it belongs to.

GraphQL
type Comment { author: [1] post: [2] }
Drag options to blanks, or click blank then click option'
AUser!
BPost!
C[User]
DString
Attempts:
3 left
💡 Hint
Common Mistakes
Using lists instead of single types.
Using String instead of User or Post types.
5fill in blank
hard

Fill all three blanks to define a schema with User, Post, and Comment types showing their relationships.

GraphQL
type User { posts: [1] } type Post { author: [2] comments: [3] }
Drag options to blanks, or click blank then click option'
A[Post!]
BUser!
C[Comment!]
DString
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up lists and single types.
Using nullable types where non-null is needed.