Bird
0
0

Which of the following is a valid alias usage in a GraphQL query?

easy📝 Conceptual Q2 of 15
GraphQL - Queries
Which of the following is a valid alias usage in a GraphQL query?
A{ userName: user { name } }
B{ user as userName { name } }
C{ user->userName { name } }
D{ user userName { name } }
Step-by-Step Solution
Solution:
  1. Step 1: Recall alias syntax

    Aliases use the format : inside the query braces.
  2. Step 2: Check each option

    { userName: user { name } } uses correct syntax. Options B, C, and D use invalid syntax.
  3. Final Answer:

    { userName: user { name } } -> Option A
  4. Quick Check:

    Alias syntax = aliasName: fieldName [OK]
Quick Trick: Use colon ':' to assign alias before field name [OK]
Common Mistakes:
  • Using 'as' instead of colon
  • Using arrows or spaces instead of colon
  • Omitting colon between alias and field

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes