SITECORE-XM-CLOUD-DEVELOPER practice question 2 of 10

A developer is tasked with creating an item using the Sitecore Authoring and Management GraphQL API. Which of the following GraphQL mutations is the correct way to create a new item?

Full set: 49 questions
Answer options
A: createOrUpdateltem
B: create Templateltem
C: createltem Correct answer
D: updateltem
Correct Answer:
C. createltem
Explanation

The Sitecore Authoring and Management GraphQL API provides a specific set of mutations for content manipulation. To create a new item, the designated mutation is createItem. This mutation requires arguments such as name, templateId, and parentId to define the new item's basic properties and its location within the content tree. The API is designed with explicit, single-purpose mutations for clarity and control over authoring operations, distinguishing creation from updates or other actions.

Why Incorrect

A. createOrUpdateItem: This mutation does not exist in the Sitecore Authoring and Management GraphQL API. The API separates create and update operations into distinct createItem and updateItem mutations.
B. createTemplateItem: This is not a valid mutation. To create an item based on a specific template (including creating a new template definition item), the standard createItem mutation is used with the appropriate templateId.
D. updateItem: This mutation is used exclusively for modifying the fields of an existing item. It cannot be used to create a new item; its purpose is to update, not to insert.

References

1. Sitecore XM Cloud Documentation, createItem: This official document explicitly defines the createItem mutation. It states, "The createItem mutation creates a new item." It also details the required arguments (name, parentId, templateId) and the return type.

Reference: Sitecore XM Cloud Documentation > GraphQL API > Authoring and Management API > Mutations > createItem.

2. Sitecore XM Cloud Documentation, The Authoring and Management GraphQL API: This overview page lists the available mutations for the API. The list includes createItem, updateItem, and deleteItem, but does not include createOrUpdateItem or createTemplateItem, confirming they are not valid operations.

Reference: Sitecore XM Cloud Documentation > GraphQL API > Authoring and Management API. (Section on "Mutations").

Scroll to Top