Bird
0
0

How can you combine query variables with default values in GraphQL? Choose the correct example.

hard📝 Application Q9 of 15
GraphQL - Queries
How can you combine query variables with default values in GraphQL? Choose the correct example.
Aquery getUsers($limit Int = 10) { users(limit: $limit) { name } }
Bquery getUsers($limit: Int!) { users(limit: $limit = 10) { name } }
Cquery getUsers($limit: Int = 10) { users(limit: $limit) { name } }
Dquery getUsers { users(limit: 10) { name } }
Step-by-Step Solution
Solution:
  1. Step 1: Recall syntax for default variable values

    Default values are assigned with = inside variable declaration parentheses.
  2. Step 2: Identify correct syntax

    query getUsers($limit: Int = 10) { users(limit: $limit) { name } } correctly declares $limit with type Int and default 10.
  3. Final Answer:

    query getUsers($limit: Int = 10) { users(limit: $limit) { name } } -> Option C
  4. Quick Check:

    Default values use = inside variable declaration [OK]
Quick Trick: Set default with = inside variable declaration [OK]
Common Mistakes:
  • Missing colon
  • Assigning default outside declaration
  • Using ! with default

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes