Bird
0
0

Given the schema:

medium📝 query result Q4 of 15
GraphQL - Resolvers
Given the schema:
type Query { book(id: ID!): Book }

and the query:
{ book(id: "2") { title author } }

What will the resolver receive as the args parameter?
Anull
B{ id: 2 }
C{ id: "2" }
D2
Step-by-Step Solution
Solution:
  1. Step 1: Understand argument types and values

    The schema defines id as non-null ID type, which is a string.
  2. Step 2: Analyze the query argument

    The query passes id: "2" as a string. The resolver receives args as an object with key id and value string "2".
  3. Final Answer:

    { id: "2" } -> Option C
  4. Quick Check:

    Args is an object with argument names and values [OK]
Quick Trick: Args is always an object with keys as argument names [OK]
Common Mistakes:
  • Assuming args is a single value
  • Confusing ID type with integer
  • Expecting args to be null if no args

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes