Bird
0
0

How do you correctly pass an argument named userId with value 10 to a GraphQL query field profile?

easy📝 Syntax Q3 of 15
GraphQL - Resolvers
How do you correctly pass an argument named userId with value 10 to a GraphQL query field profile?
A{ profile(userId: 10) { name email } }
B{ profile(userId = 10) { name email } }
C{ profile(userId => 10) { name email } }
D{ profile(userId == 10) { name email } }
Step-by-Step Solution
Solution:
  1. Step 1: Understand GraphQL argument syntax

    Arguments are passed inside parentheses after the field name using a colon to assign values.
  2. Step 2: Identify correct syntax

    { profile(userId: 10) { name email } } uses userId: 10, which is the correct syntax. Other options use invalid operators like '=', '=>', or '=='.
  3. Final Answer:

    { profile(userId: 10) { name email } } -> Option A
  4. Quick Check:

    Arguments use colon syntax [OK]
Quick Trick: Use colon ':' to assign argument values in GraphQL [OK]
Common Mistakes:
  • Using '=' instead of ':' to assign argument values
  • Using '=>' or '==' which are invalid in GraphQL arguments
  • Omitting parentheses around arguments

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes