Bird
0
0

What will be the output of this query?

medium📝 query result Q5 of 15
GraphQL - Queries
What will be the output of this query?
{ firstUser: user(id: 1) { id name } secondUser: user(id: 1) { id name } }
A{ "user": { "id": 1, "name": "Alice" } }
B{ "firstUser": { "id": 1, "name": "Alice" }, "secondUser": { "id": 1, "name": "Alice" } }
C{ "firstUser": { "id": 1, "name": "Bob" }, "secondUser": { "id": 1, "name": "Bob" } }
D{ "firstUser": { "id": 1 }, "secondUser": { "name": "Alice" } }
Step-by-Step Solution
Solution:
  1. Step 1: Recognize alias usage with same id

    Both aliases query the same user id 1, so data is identical.
  2. Step 2: Confirm output structure

    Each alias returns full user object with id and name, so both keys have same data.
  3. Final Answer:

    { "firstUser": { "id": 1, "name": "Alice" }, "secondUser": { "id": 1, "name": "Alice" } } -> Option B
  4. Quick Check:

    Aliases allow same query multiple times [OK]
Quick Trick: Aliases let you query same field multiple times with different names [OK]
Common Mistakes:
  • Expecting different data for same id
  • Confusing alias names with data values
  • Partial data returned for one alias

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes