Bird
0
0

You wrote this schema:

medium📝 Debug Q6 of 15
GraphQL - Basics and Philosophy
You wrote this schema:
type Query { user(id: ID): User }

and resolver:
user: (parent, args) => getUserById(args.id)

But queries return null always. What is the likely issue?
AThe Query type must be named RootQuery
BThe id argument should be non-nullable (ID!) in schema
CThe resolver function is missing a return statement
DThe getUserById function is undefined
Step-by-Step Solution
Solution:
  1. Step 1: Check schema argument type

    The id argument is nullable (ID), so queries may omit it causing null results.
  2. Step 2: Fix argument nullability

    Making id non-nullable (ID!) ensures queries must provide id, fixing null returns.
  3. Final Answer:

    The id argument should be non-nullable (ID!) in schema -> Option B
  4. Quick Check:

    Nullable id arg causes null results [OK]
Quick Trick: Use ID! to require id argument in queries [OK]
Common Mistakes:
  • Assuming resolver missing return
  • Thinking Query type name matters
  • Ignoring argument nullability

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes