Bird
0
0

You want to define a GraphQL type Order that includes an id (non-null ID), a list of items (each an Item type), and a total price (non-null Float). Which is the correct type definition?

hard📝 schema Q15 of 15
GraphQL - Schema Definition Language (SDL)
You want to define a GraphQL type Order that includes an id (non-null ID), a list of items (each an Item type), and a total price (non-null Float). Which is the correct type definition?
Atype Order { id: ID! items: [Item!]! total: Float! }
Btype Order { id: ID items: Item total: Float }
Ctype Order { id: ID! items: [Item]! total: Float! }
Dtype Order { id: ID! items: [Item!] total: Float }
Step-by-Step Solution
Solution:
  1. Step 1: Analyze each field requirement

    'id' must be non-null ID, 'items' is a non-null list of non-null Item, 'total' is non-null Float.
  2. Step 2: Match the correct syntax

    type Order { id: ID! items: [Item!]! total: Float! } correctly uses ID!, [Item!]! (list non-null and items non-null), and Float!.
  3. Final Answer:

    type Order { id: ID! items: [Item!]! total: Float! } -> Option A
  4. Quick Check:

    Non-null fields and list syntax correct [OK]
Quick Trick: Use [Type!]! for non-null list of non-null items [OK]
Common Mistakes:
  • Missing non-null markers (!)
  • Using list without non-null item type
  • Confusing list syntax with single type

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes