Skip to main content
More in Learn

Component Updates with the Core API

The Core API simplifies updating a component by directly targeting the component. In order to perform these operations, ensure that you have the proper authentication and user permissions.

Updating a Component

The mutation below updates a single line component:

mutation UPDATE_COMPONENT(
  $itemId: ID!
  $language: String!
  $input: ComponentInput!
) {
  updateComponent(itemId: $itemId, language: $language, component: $input) {
    ... on UpdatedComponent {
      updatedComponentPath
      item {
        id
      }
    }
    ... on BasicError {
      message
    }
  }
}

Here's what the variables look like:

{
  "itemId": "ITEM_ID",
  "language": "en",
  "input": {
    "componentId": "name",
    "singleLine": {
      "text": "Classic colors"
    }
  }
}

The arguments provided to the mutation include:

  • itemId - the ID of the item that needs to be updated
  • language - the language the item needs to be updated in
  • input - input takes in the component-related details. It requires the component ID and then, based on the component type, you would further provide the data.

In the example above, since it's a single line component, we add the text field there.

People showing thumbs up

Need further assistance?

Ask the Crystallize team or other enthusiasts in our slack community.

Join our slack community