Bird
0
0

Which of the following is the correct GraphQL syntax to define a many-to-many relationship between two types, Author and Book?

easy📝 Syntax Q3 of 15
GraphQL - Type Relationships
Which of the following is the correct GraphQL syntax to define a many-to-many relationship between two types, Author and Book?
Atype Author { books: [Book!]! } type Book { authors: [Author!]! }
Btype Author { book: Book } type Book { author: Author }
Ctype Author { books: Book } type Book { authors: Author }
Dtype Author { books: Book! } type Book { authors: Author! }
Step-by-Step Solution
Solution:
  1. Step 1: Understand many-to-many syntax

    Many-to-many uses lists on both sides to represent multiple connections.
  2. Step 2: Check options for list syntax

    type Author { books: [Book!]! } type Book { authors: [Author!]! } uses lists ([Book!]! and [Author!]!) correctly, others do not use lists properly.
  3. Final Answer:

    type Author { books: [Book!]! } type Book { authors: [Author!]! } -> Option A
  4. Quick Check:

    Many-to-many syntax = lists on both sides [OK]
Quick Trick: Many-to-many uses lists on both sides [OK]
Common Mistakes:
  • Using single object instead of list
  • Missing non-null markers
  • Confusing list syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes