Updating Attributes
Inside this guide:
Introduction
Update an Attribute
Next steps
Introduction
The updateCoreProductAttribute mutation allows you to update an Attribute.
Update an Attribute
Constructing the mutation and input
We'll be using the API Console to save time having to authenticate. Copy and paste this into your API console query section to get started. Reminder that fields can be removed from the query if you don't want the API to return them.
POST /graphql
Query
mutation ($input: UpdateCoreProductAttributeInput!) {
updateCoreProductAttribute(input: $input) {
coreProductAttribute {
id
name
type
}
errors {
path
message
}
}
}
Defining the variables
Copy and paste the block below into the query variables section of the API console and substitute the ATTRIBUTE_ID with the id of the attribute you want to update.
NOTE: The below block is creating an attribute of type TEXT, other supported types are NUMBER and DATE.
Variables
{
"input": {
"id": ATTRIBUTE_ID,
"name": "Electronics",
"type" : "TEXT"
}
}
Now press Execute Query (the play button) to send the request.
You should get back this response containing the attribute you updated.
JSON Response
{
"data": {
"updateCoreProductAttribute": {
"coreProductAttribute": {
"id": "73c513ce-c584-46e4-9c51-ddb7aba22575",
"name": "Electronics",
"type": "TEXT"
},
"errors": null
}
}
}
Next Steps
- Create Attribute - Learn how to create an attribute
- Query Attribute - Learn how to query an attribute
- Update Attribute - Learn how to update an attribute
- Delete Attribute - Learn how to delete an attribute
- Making your first call - If you're not sure how GraphQL works, start here.