Bird
0
0

Consider this query:

medium📝 query result Q5 of 15
GraphQL - Queries
Consider this query:
{ user(id: 2) { name posts { title comments { text } } } }

What data will this query return?
AOnly user's name and posts' titles
BAn error because comments are nested too deeply
COnly posts' titles and comments' text
DUser's name, posts' titles, and comments' text
Step-by-Step Solution
Solution:
  1. Step 1: Read the query fields

    The query requests name of user, nested posts with title, and nested comments with text.
  2. Step 2: Understand nested data returned

    GraphQL returns all requested nested data: user name, posts titles, and comments text.
  3. Final Answer:

    User's name, posts' titles, and comments' text -> Option D
  4. Quick Check:

    Nested fields return all requested nested data [OK]
Quick Trick: Nested queries return all requested nested fields data [OK]
Common Mistakes:
  • Assuming nested fields deeper than one level cause errors
  • Ignoring comments data in output
  • Thinking only top-level fields return

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes