0
0
GraphQLquery~10 mins

Object types 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 object type named 'Book'.

GraphQL
type Book[1] {
  id: ID!
  title: String!
  author: String!
}
Drag options to blanks, or click blank then click option'
A<
B(
C[
D{
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses or square brackets instead of curly braces.
Forgetting to open the block with any symbol.
2fill in blank
medium

Complete the code to specify that the 'id' field is non-nullable.

GraphQL
type User {
  id: ID[1]
  name: String
}
Drag options to blanks, or click blank then click option'
A#
B?
C!
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using question mark or other symbols instead of exclamation mark.
Leaving out the non-nullable indicator.
3fill in blank
hard

Fix the error in the object type definition by completing the code.

GraphQL
type Author {
  id: ID!
  name: String!
  books: [Book][1]
}
Drag options to blanks, or click blank then click option'
A!
B?
C*
D#
Attempts:
3 left
💡 Hint
Common Mistakes
Placing the exclamation mark inside the brackets instead of outside.
Using other symbols instead of exclamation mark.
4fill in blank
hard

Fill both blanks to define a 'Query' type with a field 'book' that takes an 'id' argument of type 'ID!'.

GraphQL
type Query {
  book(id: [1]): Book[2]
}
Drag options to blanks, or click blank then click option'
AID!
BID
C!
D?
Attempts:
3 left
💡 Hint
Common Mistakes
Using nullable types for required arguments.
Omitting the exclamation mark for non-nullable return types.
5fill in blank
hard

Fill all three blanks to define a 'Mutation' type with a 'createBook' field that takes 'title' and 'author' arguments as non-nullable strings and returns a non-nullable 'Book'.

GraphQL
type Mutation {
  createBook(title: [1], author: [2]): Book[3]
}
Drag options to blanks, or click blank then click option'
AString!
BString
C!
DID!
Attempts:
3 left
💡 Hint
Common Mistakes
Using nullable types for required arguments.
Forgetting the exclamation mark on the return type.