Bird
0
0

You have this GraphQL schema:

medium📝 Debug Q14 of 15
GraphQL - Type Relationships
You have this GraphQL schema:
type Category { products: [Product] } type Product { category: Category }

But your query for category { products { category { id } }} returns null for category inside products. What is the likely cause?
AThe <code>products</code> field should not be a list
BGraphQL does not support nested bidirectional queries
CThe <code>category</code> field in <code>Product</code> is not properly resolved or linked
DThe query syntax is invalid
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the schema and query

    Schema defines bidirectional links. Query asks for category's products and each product's category id.
  2. Step 2: Identify why nested category is null

    If nested category is null, likely the resolver for category in Product is missing or incorrect.
  3. Final Answer:

    The category field in Product is not properly resolved or linked -> Option C
  4. Quick Check:

    Missing resolver causes null nested fields [OK]
Quick Trick: Null nested fields often mean missing resolver functions [OK]
Common Mistakes:
  • Assuming GraphQL can't do nested bidirectional queries
  • Thinking list types cause nulls
  • Blaming query syntax without error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes