Bird
0
0

You want to create a mutation that accepts a list of input objects to add multiple users at once. Which input type definition and mutation argument are correct?

hard📝 Application Q8 of 15
GraphQL - Schema Definition Language (SDL)
You want to create a mutation that accepts a list of input objects to add multiple users at once. Which input type definition and mutation argument are correct?
Ainput UserInput { name: String!, age: Int } mutation addUsers($users: [UserInput!]!) { addUsers(users: $users) { id name } }
Binput UserInput { name: String!, age: Int } mutation addUsers($users: UserInput!) { addUsers(users: $users) { id name } }
Cinput UserInput { name: String!, age: Int } mutation addUsers($users: [UserInput]) { addUsers(users: $users) { id name } }
Dinput UserInput { name: String!, age: Int } mutation addUsers($users: [UserInput!]) { addUsers(users: $users) { id name } }
Step-by-Step Solution
Solution:
  1. Step 1: Understand list input type syntax

    To accept a list of non-null UserInput objects, use [UserInput!]! meaning list is non-null and items are non-null.
  2. Step 2: Check mutation argument matches input type

    input UserInput { name: String!, age: Int } mutation addUsers($users: [UserInput!]!) { addUsers(users: $users) { id name } } correctly declares variable as $users: [UserInput!]! and passes it as argument.
  3. Final Answer:

    input UserInput { name: String!, age: Int } mutation addUsers($users: [UserInput!]!) { addUsers(users: $users) { id name } } -> Option A
  4. Quick Check:

    Use [Type!]! for non-null list of non-null items [OK]
Quick Trick: Use [Type!]! for required list of required items [OK]
Common Mistakes:
  • Omitting exclamation marks causing nullable lists or items
  • Passing single object instead of list
  • Using [Type] without non-null modifiers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes