collection Updatemutation
mutation
2024-01
Requires write
access scope. Also: The app must have access to the input fields used to update the collection. Further, the store must not be on the Starter or Retail plans and user must have a permission to update collection.
Updates a collection.
Arguments
The updated properties for the collection.
Was this section helpful?
CollectionUpdatePayload returns
The updated collection.
The asynchronous job updating the products based on the new rule set.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Examples
Hide code
DescriptionCopy
mutation updateCollectionRules($input: CollectionInput!) { collectionUpdate(input: $input) { collection { id title description handle ruleSet { rules { column relation condition } appliedDisjunctively } } userErrors { field message } } }
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2024-01/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation updateCollectionRules($input: CollectionInput!) { collectionUpdate(input: $input) { collection { id title description handle ruleSet { rules { column relation condition } appliedDisjunctively } } userErrors { field message } } }", "variables": { "input": { "id": "gid://shopify/Collection/442946009", "ruleSet": { "rules": [ { "column": "IS_PRICE_REDUCED", "relation": "IS_NOT_SET", "condition": "" } ], "appliedDisjunctively": true } } } }'
const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation updateCollectionRules($input: CollectionInput!) { collectionUpdate(input: $input) { collection { id title description handle ruleSet { rules { column relation condition } appliedDisjunctively } } userErrors { field message } } }`, { variables: { "input": { "id": "gid://shopify/Collection/442946009", "ruleSet": { "rules": [ { "column": "IS_PRICE_REDUCED", "relation": "IS_NOT_SET", "condition": "" } ], "appliedDisjunctively": true } } }, }, ); const data = await response.json();
session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation updateCollectionRules($input: CollectionInput!) { collectionUpdate(input: $input) { collection { id title description handle ruleSet { rules { column relation condition } appliedDisjunctively } } userErrors { field message } } } QUERY variables = { "input": { "id": "gid://shopify/Collection/442946009", "ruleSet": { "rules": [{"column"=>"IS_PRICE_REDUCED", "relation"=>"IS_NOT_SET", "condition"=>""}], "appliedDisjunctively": true } } } response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation updateCollectionRules($input: CollectionInput!) { collectionUpdate(input: $input) { collection { id title description handle ruleSet { rules { column relation condition } appliedDisjunctively } } userErrors { field message } } }`, "variables": { "input": { "id": "gid://shopify/Collection/442946009", "ruleSet": { "rules": [ { "column": "IS_PRICE_REDUCED", "relation": "IS_NOT_SET", "condition": "" } ], "appliedDisjunctively": true } } }, }, });
use Shopify\Clients\Graphql; $client = new Graphql("your-development-store.myshopify.com", $accessToken); $query = <<<QUERY mutation updateCollectionRules($input: CollectionInput!) { collectionUpdate(input: $input) { collection { id title description handle ruleSet { rules { column relation condition } appliedDisjunctively } } userErrors { field message } } } QUERY; $variables = [ "input" => [ "id" => "gid://shopify/Collection/442946009", "ruleSet" => [ "rules" => [{"column"=>"IS_PRICE_REDUCED", "relation"=>"IS_NOT_SET", "condition"=>""}], "appliedDisjunctively" => true, ], ], ]; $response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{ "input": { "id": "gid://shopify/Collection/442946009", "ruleSet": { "rules": [ { "column": "IS_PRICE_REDUCED", "relation": "IS_NOT_SET", "condition": "" } ], "appliedDisjunctively": true } } }
Hide code
Response
JSON
{ "collectionUpdate": { "collection": null, "userErrors": [ { "field": [ "id" ], "message": "Cannot update rule set of a custom collection" } ] } }