Bird
0
0

Consider the input type:

medium📝 Predict Output Q5 of 15
GraphQL - Mutations
Consider the input type:
input FilterInput { minPrice: Float, maxPrice: Float }

and query:
query getProducts($filter: FilterInput) { products(filter: $filter) { id price } }

What will be the result if you call the query with { "filter": { "minPrice": 20 } }?
AQuery fails due to missing maxPrice
BReturns products with price <= 20
CReturns all products ignoring filter
DReturns products with price >= 20
Step-by-Step Solution
Solution:
  1. Step 1: Understand optional fields in input types

    Both minPrice and maxPrice are optional.
  2. Step 2: Analyze filter behavior with only minPrice

    Filter applies minimum price condition only, so products with price >= 20 are returned.
  3. Final Answer:

    Returns products with price >= 20 -> Option D
  4. Quick Check:

    Optional input fields filter accordingly [OK]
Quick Trick: Optional input fields can be partially provided [OK]
Common Mistakes:
  • Assuming missing optional fields cause errors
  • Confusing minPrice and maxPrice roles
  • Expecting query to fail without all fields

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes