Anchor to productReorderMediaproduct
productReorderMedia
mutation
Requires access scope. Also: The user must have a permission to reorder the media attached to a product.
Asynchronously reorders the media attached to a product.
Anchor to Arguments
Arguments
- •ID!required
The ID of the product on which to reorder medias.
- Anchor to movesmoves•[Move
Input!]! required A list of moves to perform which will be evaluated in order.
Was this section helpful?
Anchor to ProductReorderMediaPayload returnsProductReorderMediaPayload returns
- •
The asynchronous job which reorders the media.
- Anchor to mediaUserErrorsmedia•
User Errors [MediaUser non-nullError!]! The list of errors that occurred from executing the mutation.
- Anchor to userErrorsuser•
Errors The list of errors that occurred from executing the mutation.
Was this section helpful?
- Reorder a product's media
- productReorderMedia reference
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation productReorderMedia($id: ID!, $moves: [MoveInput!]!) {6 productReorderMedia(id: $id, moves: $moves) {7 job {8 id9 }10 }11 }`,12 {13 variables: {14 "id": "gid://shopify/Product/108828309",15 "moves": [16 {17 "id": "gid://shopify/MediaImage/183532652",18 "newPosition": "2"19 },20 {21 "id": "gid://shopify/MediaImage/731367280",22 "newPosition": "3"23 }24 ]25 },26 },27);2829const data = await response.json();30
mutation productReorderMedia($id: ID!, $moves: [MoveInput!]!) {
productReorderMedia(id: $id, moves: $moves) {
job {
id
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation productReorderMedia($id: ID!, $moves: [MoveInput!]!) { productReorderMedia(id: $id, moves: $moves) { job { id } } }",
"variables": {
"id": "gid://shopify/Product/108828309",
"moves": [
{
"id": "gid://shopify/MediaImage/183532652",
"newPosition": "2"
},
{
"id": "gid://shopify/MediaImage/731367280",
"newPosition": "3"
}
]
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation productReorderMedia($id: ID!, $moves: [MoveInput!]!) {
productReorderMedia(id: $id, moves: $moves) {
job {
id
}
}
}`,
{
variables: {
"id": "gid://shopify/Product/108828309",
"moves": [
{
"id": "gid://shopify/MediaImage/183532652",
"newPosition": "2"
},
{
"id": "gid://shopify/MediaImage/731367280",
"newPosition": "3"
}
]
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation productReorderMedia($id: ID!, $moves: [MoveInput!]!) {
productReorderMedia(id: $id, moves: $moves) {
job {
id
}
}
}`,
"variables": {
"id": "gid://shopify/Product/108828309",
"moves": [
{
"id": "gid://shopify/MediaImage/183532652",
"newPosition": "2"
},
{
"id": "gid://shopify/MediaImage/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 productReorderMedia($id: ID!, $moves: [MoveInput!]!) {
productReorderMedia(id: $id, moves: $moves) {
job {
id
}
}
}
QUERY
variables = {
"id": "gid://shopify/Product/108828309",
"moves": [{"id"=>"gid://shopify/MediaImage/183532652", "newPosition"=>"2"}, {"id"=>"gid://shopify/MediaImage/731367280", "newPosition"=>"3"}]
}
response = client.query(query: query, variables: variables)
Input variables
JSON1{2 "id": "gid://shopify/Product/108828309",3 "moves": [4 {5 "id": "gid://shopify/MediaImage/183532652",6 "newPosition": "2"7 },8 {9 "id": "gid://shopify/MediaImage/731367280",10 "newPosition": "3"11 }12 ]13}
Response
JSON1{2 "productReorderMedia": {3 "job": {4 "id": "gid://shopify/Job/6dfa599a-a426-4030-8f10-6564abc465f9"5 }6 }7}