You want to optimize a GraphQL query that fetches a list of books with authors. How can default resolvers help reduce custom code?
hard📝 Application Q8 of 15
GraphQL - Resolvers
You want to optimize a GraphQL query that fetches a list of books with authors. How can default resolvers help reduce custom code?
ABy automatically resolving fields that match parent object keys without writing resolvers
BBy caching all query results internally
CBy batching database calls automatically
DBy requiring explicit resolver functions for nested fields
Step-by-Step Solution
Solution:
Step 1: Understand default resolver benefits
Default resolvers automatically resolve fields by matching parent object keys, reducing the need for custom resolver code.
Step 2: Evaluate optimization options
By automatically resolving fields that match parent object keys without writing resolvers correctly describes this benefit. Options A and B describe batching and caching which default resolvers do not do. By requiring explicit resolver functions for nested fields is opposite to reducing custom code.
Final Answer:
By automatically resolving fields that match parent object keys without writing resolvers -> Option A
Quick Check:
Default resolvers reduce code by auto-resolving matching fields [OK]
Quick Trick:Default resolvers reduce code by auto-resolving matching fields [OK]
Common Mistakes:
Confusing default resolvers with caching or batching features
Thinking default resolvers require explicit functions for nested fields