Complete the code to define a many-to-many relationship between Author and Book types using GraphQL schema syntax.
type Author {
id: ID!
name: String!
books: [[1]!]!
}Author or scalar types instead of Book.The books field in Author should be a list of Book types to represent the many-to-many relationship.
Complete the code to define the reciprocal many-to-many relationship from Book back to Author.
type Book {
id: ID!
title: String!
authors: [[1]!]!
}Book or scalar types instead of Author.The authors field in Book should be a list of Author types to link books back to their authors.
Fix the error in this GraphQL schema snippet that tries to define a many-to-many relationship but uses incorrect syntax.
type Author {
id: ID!
name: String!
books: [1]
}Book without list brackets.[Book] without the non-null marker on the list.The field books should be a non-null list of Book types, so [Book]! is correct.
Fill both blanks to complete the GraphQL schema for a join type AuthorBook that connects Author and Book by their IDs.
type AuthorBook {
authorId: [1]!
bookId: [2]!
}String or Int instead of ID.Boolean which is not suitable for IDs.Both authorId and bookId should be of type ID to uniquely identify the related records.
Fill all three blanks to complete a GraphQL query that fetches authors with their books, filtering books by title containing 'GraphQL'.
query {
authors {
name
books(filter: { title: { [1]: "GraphQL" } }) {
[2]
[3]
}
}
}equals instead of contains for filtering.id and title fields.The filter uses contains to find books with titles containing 'GraphQL'. The query selects id and title fields of those books.