Bird
0
0

Given the input type:

medium📝 Predict Output Q4 of 15
GraphQL - Mutations
Given the input type:
input ProductInput { name: String!, price: Float }

and mutation:
mutation addProduct($product: ProductInput!) { createProduct(input: $product) { id name } }

What happens if you call this mutation with { "product": { "price": 10.5 } }?
AMutation fails due to missing required 'name' field
BMutation succeeds and creates product with null name
CMutation succeeds and ignores missing 'name' field
DMutation fails due to invalid price type
Step-by-Step Solution
Solution:
  1. Step 1: Check required fields in input type

    The field name is marked with !, so it is required.
  2. Step 2: Analyze provided input

    The input only provides price, missing required name.
  3. Final Answer:

    Mutation fails due to missing required 'name' field -> Option A
  4. Quick Check:

    Required input missing = error [OK]
Quick Trick: Required input fields must be provided or mutation fails [OK]
Common Mistakes:
  • Assuming missing required fields default to null
  • Ignoring exclamation mark meaning
  • Confusing optional and required fields

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes