Bird
0
0

Identify the error in this GraphQL type definition:

medium📝 Debug Q14 of 15
GraphQL - Schema Definition Language (SDL)
Identify the error in this GraphQL type definition:
type Product {
  id: ID
  price: Float!
  name: String!
  description: String
  price: Int
}
AMissing exclamation mark on 'id' field
BIncorrect type 'Float!' for price
CDuplicate field name 'price' with different types
DDescription field cannot be optional
Step-by-Step Solution
Solution:
  1. Step 1: Review all fields for correctness

    Notice that 'price' is declared twice with different types: Float! and Int.
  2. Step 2: Understand GraphQL rules on field names

    Field names must be unique within a type; duplicates cause errors.
  3. Final Answer:

    Duplicate field name 'price' with different types -> Option C
  4. Quick Check:

    Duplicate fields cause errors [OK]
Quick Trick: Check for repeated field names in type definitions [OK]
Common Mistakes:
  • Ignoring duplicate field names
  • Thinking missing '!' is always an error
  • Assuming optional fields are invalid

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes