Anchor to productReorderImagesproduct
productReorderImages
mutationDeprecated
Requires access scope. Also: The user must have a permission to reorder product images.
Asynchronously reorders a set of images for a given product. Use instead.
Anchor to Arguments
Arguments
- •ID!required
The ID of the product on which to reorder images.
- Anchor to movesmoves•[Move
Input!]! required A list of moves to perform which will be evaluated in order.
Was this section helpful?
Anchor to ProductReorderImagesPayload returnsProductReorderImagesPayload returns
- •
The asynchronous job which reorders the images.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
Was this section helpful?
- Reorder a product's images
- productReorderImages reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation productReorderImages($id: ID!, $moves: [MoveInput!]!) {
productReorderImages(id: $id, moves: $moves) {
job {
id
}
}
}`,
{
variables: {
"id": "gid://shopify/Product/108828309",
"moves": [
{
"id": "gid://shopify/ProductImage/183532652",
"newPosition": "2"
},
{
"id": "gid://shopify/ProductImage/731367280",
"newPosition": "3"
}
]
},
},
);
const data = await response.json();
mutation productReorderImages($id: ID!, $moves: [MoveInput!]!) {
productReorderImages(id: $id, moves: $moves) {
job {
id
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation productReorderImages($id: ID!, $moves: [MoveInput!]!) { productReorderImages(id: $id, moves: $moves) { job { id } } }",
"variables": {
"id": "gid://shopify/Product/108828309",
"moves": [
{
"id": "gid://shopify/ProductImage/183532652",
"newPosition": "2"
},
{
"id": "gid://shopify/ProductImage/731367280",
"newPosition": "3"
}
]
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation productReorderImages($id: ID!, $moves: [MoveInput!]!) {
productReorderImages(id: $id, moves: $moves) {
job {
id
}
}
}`,
{
variables: {
"id": "gid://shopify/Product/108828309",
"moves": [
{
"id": "gid://shopify/ProductImage/183532652",
"newPosition": "2"
},
{
"id": "gid://shopify/ProductImage/731367280",
"newPosition": "3"
}
]
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation productReorderImages($id: ID!, $moves: [MoveInput!]!) {
productReorderImages(id: $id, moves: $moves) {
job {
id
}
}
}`,
"variables": {
"id": "gid://shopify/Product/108828309",
"moves": [
{
"id": "gid://shopify/ProductImage/183532652",
"newPosition": "2"
},
{
"id": "gid://shopify/ProductImage/731367280",
"newPosition": "3"
}
]
},
},
});
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 productReorderImages($id: ID!, $moves: [MoveInput!]!) {
productReorderImages(id: $id, moves: $moves) {
job {
id
}
}
}
QUERY
variables = {
"id": "gid://shopify/Product/108828309",
"moves": [{"id"=>"gid://shopify/ProductImage/183532652", "newPosition"=>"2"}, {"id"=>"gid://shopify/ProductImage/731367280", "newPosition"=>"3"}]
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"id": "gid://shopify/Product/108828309",
"moves": [
{
"id": "gid://shopify/ProductImage/183532652",
"newPosition": "2"
},
{
"id": "gid://shopify/ProductImage/731367280",
"newPosition": "3"
}
]
}
Response
JSON{
"productReorderImages": {
"job": {
"id": "gid://shopify/Job/9b108d8e-4317-40a9-9570-17682a8891d5"
}
}
}