0
0
GraphQLquery~10 mins

Many-to-many relationships 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 many-to-many relationship between Author and Book types using GraphQL schema syntax.

GraphQL
type Author {
  id: ID!
  name: String!
  books: [[1]!]!
}
Drag options to blanks, or click blank then click option'
AString
BBook
CAuthor
DID
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong type like Author or scalar types instead of Book.
Not using a list to represent multiple books.
2fill in blank
medium

Complete the code to define the reciprocal many-to-many relationship from Book back to Author.

GraphQL
type Book {
  id: ID!
  title: String!
  authors: [[1]!]!
}
Drag options to blanks, or click blank then click option'
ABook
BString
CAuthor
DID
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong type like Book or scalar types instead of Author.
Not using a list to represent multiple authors.
3fill in blank
hard

Fix the error in this GraphQL schema snippet that tries to define a many-to-many relationship but uses incorrect syntax.

GraphQL
type Author {
  id: ID!
  name: String!
  books: [1]
}
Drag options to blanks, or click blank then click option'
A[Book]!
B[Book]
CBook!
DBook
Attempts:
3 left
💡 Hint
Common Mistakes
Using just Book without list brackets.
Using [Book] without the non-null marker on the list.
4fill in blank
hard

Fill both blanks to complete the GraphQL schema for a join type AuthorBook that connects Author and Book by their IDs.

GraphQL
type AuthorBook {
  authorId: [1]!
  bookId: [2]!
}
Drag options to blanks, or click blank then click option'
AID
BString
CInt
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using String or Int instead of ID.
Using Boolean which is not suitable for IDs.
5fill in blank
hard

Fill all three blanks to complete a GraphQL query that fetches authors with their books, filtering books by title containing 'GraphQL'.

GraphQL
query {
  authors {
    name
    books(filter: { title: { [1]: "GraphQL" } }) {
      [2]
      [3]
    }
  }
}
Drag options to blanks, or click blank then click option'
Acontains
Bid
Ctitle
Dequals
Attempts:
3 left
💡 Hint
Common Mistakes
Using equals instead of contains for filtering.
Not selecting both id and title fields.