Bird
0
0

What is wrong with this GraphQL query if the client wants only the user's email but the query is:

medium📝 Debug Q7 of 15
GraphQL - Basics and Philosophy
What is wrong with this GraphQL query if the client wants only the user's email but the query is:
{ user { id name email } }
AIt causes under-fetching by missing email
BIt has invalid syntax due to extra fields
CIt causes over-fetching by requesting unnecessary fields
DIt will cause a server error
Step-by-Step Solution
Solution:
  1. Step 1: Analyze requested fields

    The query requests id, name, and email.
  2. Step 2: Compare with client needs

    The client only needs email, so id and name are extra.
  3. Final Answer:

    It causes over-fetching by requesting unnecessary fields -> Option C
  4. Quick Check:

    Extra fields = Over-fetching [OK]
Quick Trick: Request only needed fields to avoid over-fetching [OK]
Common Mistakes:
  • Thinking extra fields cause syntax errors
  • Confusing over-fetching with under-fetching
  • Assuming server errors for extra fields

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes