Bird
0
0

Given this schema snippet:

medium📝 Debug Q6 of 15
GraphQL - Type Relationships
Given this schema snippet:
type Manager { id: ID! office: Office }
type Office { id: ID! roomNumber: String }

What error occurs if the resolver for office returns an array instead of a single Office object?
ANo error, GraphQL automatically converts list to single object
BGraphQL error: Expected single object but got list
CThe query returns null silently
DGraphQL throws a syntax error at schema definition
Step-by-Step Solution
Solution:
  1. Step 1: Understand expected return type

    The office field expects a single Office object, not a list.
  2. Step 2: Analyze resolver return mismatch

    If the resolver returns a list, GraphQL will raise a runtime error indicating type mismatch.
  3. Final Answer:

    GraphQL error: Expected single object but got list -> Option B
  4. Quick Check:

    Resolver must match schema type exactly [OK]
Quick Trick: Resolver return type must match schema field type [OK]
Common Mistakes:
  • Returning lists for single object fields
  • Expecting GraphQL to auto-convert types
  • Ignoring runtime errors from type mismatches

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes