Bird
0
0

You want to fetch two different posts by their IDs in one query and rename their fields to firstPost and secondPost. Which query correctly does this?

hard📝 Application Q8 of 15
GraphQL - Queries
You want to fetch two different posts by their IDs in one query and rename their fields to firstPost and secondPost. Which query correctly does this?
A{ post(id: 1): firstPost { title } post(id: 2): secondPost { title } }
B{ post1: post(id: 1) { title } post1: post(id: 2) { title } }
C{ post(id: 1) as firstPost { title } post(id: 2) as secondPost { title } }
D{ firstPost: post(id: 1) { title } secondPost: post(id: 2) { title } }
Step-by-Step Solution
Solution:
  1. Step 1: Use alias syntax correctly

    Alias must be before colon, then field with arguments.
  2. Step 2: Check uniqueness and syntax

    { firstPost: post(id: 1) { title } secondPost: post(id: 2) { title } } uses unique aliases and correct syntax; others have duplicate aliases or wrong syntax.
  3. Final Answer:

    { firstPost: post(id: 1) { title } secondPost: post(id: 2) { title } } -> Option D
  4. Quick Check:

    Unique aliases with colon before field [OK]
Quick Trick: Alias: field(args) { selection } is correct format [OK]
Common Mistakes:
  • Using duplicate alias names
  • Using 'as' or colon after field incorrectly
  • Misplacing alias after field

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes