Bird
0
0

You need to delete several posts by their IDs in a single GraphQL mutation. Which mutation design is most appropriate?

hard📝 Application Q8 of 15
GraphQL - Mutations

You need to delete several posts by their IDs in a single GraphQL mutation. Which mutation design is most appropriate?

Amutation { deletePosts(postId: "101") { success } }
Bmutation { deletePost(postId: "101") { success } deletePost(postId: "102") { success } }
Cmutation { deletePosts(ids: "101,102,103") { success } }
Dmutation { deletePosts(postIds: ["101", "102", "103"]) { success count } }
Step-by-Step Solution
Solution:
  1. Step 1: Understand batch deletion

    Deleting multiple items in one mutation typically requires passing a list of IDs.
  2. Step 2: Analyze options

    mutation { deletePosts(postIds: ["101", "102", "103"]) { success count } } correctly passes an array of strings as postIds. mutation { deletePost(postId: "101") { success } deletePost(postId: "102") { success } } calls multiple mutations separately, which is inefficient. mutation { deletePosts(ids: "101,102,103") { success } } passes a single string instead of a list. mutation { deletePosts(postId: "101") { success } } passes only one ID.
  3. Final Answer:

    mutation { deletePosts(postIds: ["101", "102", "103"]) { success count } } -> Option D
  4. Quick Check:

    Batch deletes use list arguments, not multiple calls [OK]
Quick Trick: Use list arguments for batch delete mutations [OK]
Common Mistakes:
  • Calling multiple single-item delete mutations instead of batch
  • Passing comma-separated string instead of list
  • Using singular argument names for multiple IDs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes