Setting a new position for products in a collection using GraphQL API does not work

succubusnl
Shopify Partner
3 0 0

// Add product 9226170532176 to collection 615709376848
curl -X POST "xxxx" -H "Content-Type: application/json" -H "X-Shopify-Access-Token: <access token>" -d "{\"query\": \"mutation collectionAddProducts($id: ID!, $productIds: [ID!]!) { collectionAddProducts(id: $id, productIds: $productIds) { collection { id } userErrors { field message } } }\", \"variables\": { \"id\": \"gid://shopify/Collection/615709376848\", \"productIds\": [\"gid://shopify/Product/9226170532176\"] }}"

 

// Move Product 9226170532176 in Collection 615709376848 to New Position 22
curl -X POST "xxxxx" -H "Content-Type: application/json" -H "X-Shopify-Access-Token: <access token>" -d "{\"query\": \"mutation collectionReorderProducts($id: ID!, $moves: [MoveInput!]!) { collectionReorderProducts(id: $id, moves: $moves) { job { id } userErrors { field message } } }\", \"variables\": { \"id\": \"gid://shopify/Collection/615709376848\", \"moves\": [{\"id\": \"gid://shopify/Product/9226170532176\", \"newPosition\": \"22\"}] }}"

 

Somehow I cannot set a new position for my products using GraphQL. The Collection is set to manual order. Thanks for the help!

 

Reply 1 (1)
succubusnl
Shopify Partner
3 0 0

Hi! the collection is set to manual sorting. When I using the REST API it works, but when using the GraphQL API it does not.