Reordering images with productReorderMedia graphql endpoint

Hello,
Im using grapql for various tasks, and usually everything works as intended.
This time i wanted to use productReorderMedia endpoint in graphQL to reorder images on a product.
In response im getting response “OK”, but job id is null and images are not being reordered (checked manually on product page 30 minutes after calling api).
No errors in response, not sure what’s wrong.

mutation i used:

mutation productReorderMedia($id: ID!, $moves: [MoveInput!]!) {
    productReorderMedia(id: $id, moves: $moves) {
        job {
            id
        }
    }
}

with variables as described in api documentation:

https://shopify.dev/docs/api/admin-graphql/2024-01/mutations/productReorderMedia

Im using grapql version from january:

https://<mystore>/admin/api/2024-01/graphql.json

Is there something im missing?

Two things you could check here are:

  • Ensure that the $id in your mutation is the product’s GraphQL ID, not just the numeric product ID.
  • Confirm that the $moves array is correctly structured with valid mediaId and position fields.

Test this out and see if it resolves your issue.

pretty sure those are correct, but just to be sure:
Id of the product that i want to mutate:

gid://shopify/Product/

entries in moves array:

```markup
{ id = "gid://shopify/ProductImage/

Response i get is 200 OK, with cost: 10, throttle status: currentlyAvailable 1990 and null for JobId, but the order is still not changed when i check manually on shopify web page

(covered numeric id's for security reasons, but in a message im sending those are filled of course)

UPDATE:
I just noticed that newPosition type in doc is: UnsignedInt64!

and i was sending string,
however,
when sending integer, i have the following error:

```markup
Variable $moves of type [MoveInput!]! was provided invalid value for 0.newPosition (UnsignedInt64 '1' must be encoded as a string), 1.newPosition (UnsignedInt64 '2' must be encoded as a string)

@Liam i would be grateful for either fix or pointers how to do it right :slightly_smiling_face:

@rko_tilt Were you able to figure this out?

I keep getting a success message without a job id as well but can’t seem to figure it out.

Show More

[data] => Array
(
[reorderProductMedia0] => Array
(
[job] =>
)

)

[extensions] => Array
(
[cost] => Array
(
[requestedQueryCost] => 10
[actualQueryCost] => 10
[throttleStatus] => Array
(
[maximumAvailable] => 2000
[currentlyAvailable] => 1990
[restoreRate] => 100
)

)

)

I did, it turns out that reorderMedia endpoint, in “moves” needs media image ids, which are different that regular image ids (tho they point to the same resource).
To get those i had to get “media” from graphQL instead of “images”.

Now i have another problem, when getting product from grahpql
https://shopify.dev/docs/api/admin-graphql/2024-01/objects/MediaImage
im sometimes getting null in “Image”, even tho it’s supposed to return null only if image is not ready

Thank you! I got it working. So are you getting the null right after you upload a new image or even when its an existing image?

Existing images, status of all of them is “READY”. It’s really wierd because it happens only with some of the images, most of them work correctly, so for example in one product i have 32 images, 27 always work fine, 5 of them always return null in “image” field, even tho other fields are filled correctly (including Preview field)

Hi, there

could you share your variables json?