Bird
0
0

You want to define a GraphQL object type Author that includes a list of Book objects. Which is the correct way to define the books field?

hard📝 Application Q15 of 15
GraphQL - Schema Definition Language (SDL)
You want to define a GraphQL object type Author that includes a list of Book objects. Which is the correct way to define the books field?
Abooks: [Book]
Bbooks: Book[]
Cbooks: List<Book>
Dbooks: {Book}
Step-by-Step Solution
Solution:
  1. Step 1: Recall GraphQL list syntax

    GraphQL uses square brackets around a type to indicate a list, e.g., [Book].
  2. Step 2: Evaluate each option

    books: [Book] uses correct GraphQL syntax. Options A, B, and C use syntax from other languages or invalid formats.
  3. Final Answer:

    books: [Book] -> Option A
  4. Quick Check:

    Lists use square brackets in GraphQL [OK]
Quick Trick: Use square brackets for lists in GraphQL types [OK]
Common Mistakes:
  • Using array syntax from other languages
  • Using curly braces instead of brackets
  • Confusing list syntax with generics

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes