Bird
0
0

Identify the error in this GraphQL object type definition:

medium📝 Debug Q14 of 15
GraphQL - Schema Definition Language (SDL)
Identify the error in this GraphQL object type definition:
type Product {
  id: ID!
  name: String
  price: Float
  price: Int
}
AID type cannot have exclamation mark
BMissing exclamation mark on 'name' field
CDuplicate field name 'price' with different types
DObject type must have at least one field
Step-by-Step Solution
Solution:
  1. Step 1: Review field names and types

    The field price is declared twice with different types (Float and Int), which is invalid.
  2. Step 2: Check other options

    Exclamation mark on ID! is valid for non-null. Fields can be optional. Object type can have multiple fields.
  3. Final Answer:

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

    Field names must be unique in object type [OK]
Quick Trick: Field names must be unique in object types [OK]
Common Mistakes:
  • Allowing duplicate field names
  • Misunderstanding non-null syntax
  • Thinking object types need all fields non-null

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes