Bird
0
0

You want to fetch a list of books published after year 2000 using a GraphQL query with an argument publishedAfter. Which query correctly uses the args to achieve this?

hard📝 Application Q15 of 15
GraphQL - Resolvers
You want to fetch a list of books published after year 2000 using a GraphQL query with an argument publishedAfter. Which query correctly uses the args to achieve this?
A{ books["publishedAfter": 2000] { title author } }
B{ books { title author publishedAfter: 2000 } }
C{ books(publishedAfter: 2000) { title author } }
D{ books(publishedAfter = 2000) { title author } }
Step-by-Step Solution
Solution:
  1. Step 1: Understand how to pass args in GraphQL

    Arguments must be inside parentheses after the field name, using colon to assign values.
  2. Step 2: Evaluate each option

    { books(publishedAfter: 2000) { title author } } correctly uses parentheses and colon. { books { title author publishedAfter: 2000 } } places argument inside selection set which is invalid. { books(publishedAfter = 2000) { title author } } uses equals sign instead of colon. { books["publishedAfter": 2000] { title author } } uses brackets and quotes incorrectly.
  3. Final Answer:

    { books(publishedAfter: 2000) { title author } } -> Option C
  4. Quick Check:

    Args inside parentheses with colon [OK]
Quick Trick: Args go inside parentheses with colon [OK]
Common Mistakes:
  • Placing args inside selection set
  • Using equals sign instead of colon
  • Using brackets instead of parentheses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes