Bird
0
0

Given this schema snippet:

medium📝 Debug Q6 of 15
GraphQL - Type Relationships
Given this schema snippet:
type Product { id: ID name: String category: Category } type Category { id: ID name: String }

Which of the following query definitions will cause an error?
A{ product(id: "10") { name category { name } } }
B{ product(id: "10") { name } }
C{ product(id: "10") { name category { id } } }
D{ product(id: "10") { name category name } }
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the query fields

    { product(id: "10") { name category name } } tries to get 'category' as a scalar and also 'name' directly inside product.
  2. Step 2: Understand GraphQL field types

    'category' is an object type, so you must select subfields inside it, not alongside it.
  3. Final Answer:

    { product(id: "10") { name category name } } -> Option D
  4. Quick Check:

    Object fields need subfields, can't mix with scalars = B [OK]
Quick Trick: Select subfields for object types, not scalar fields directly [OK]
Common Mistakes:
  • Selecting object field and scalar field side-by-side
  • Forgetting to specify subfields for object types
  • Assuming all fields are scalars

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes