Bird
0
0

Given this schema:

medium📝 query result Q4 of 15
GraphQL - Type Relationships
Given this schema:
type Employee { id: ID! name: String desk: Desk }
type Desk { id: ID! location: String }

What will this query return?
{ employee(id: "5") { name desk { location } } }

Assuming employee with id "5" has a desk assigned.
AThe employee's name and the location of their desk
BOnly the employee's name, desk will be null
CAn error because desk is not a list
DThe employee's name and a list of desk locations
Step-by-Step Solution
Solution:
  1. Step 1: Understand schema and query

    The Employee type has a one-to-one desk field of type Desk.
  2. Step 2: Analyze query result

    The query requests name and nested desk.location. Since the employee has a desk, both fields will be returned.
  3. Final Answer:

    The employee's name and the location of their desk -> Option A
  4. Quick Check:

    One-to-one returns nested object if exists [OK]
Quick Trick: One-to-one returns nested object if present [OK]
Common Mistakes:
  • Assuming desk returns a list
  • Expecting null when desk exists
  • Confusing one-to-one with one-to-many

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes