Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

GraphQL "collectionReorderProducts" calls from app not working (but direct to API works)

GraphQL "collectionReorderProducts" calls from app not working (but direct to API works)

Kris_Doyle
Shopify Partner
140 1 44

Calls to the GraphQL collectionReorderProducts endpoint are returning a job ID, and when I query the ID, the job says "done", but the sort order of the collection is never changed; everything remains in the same position.

 

There are no errors returned and the sort order never changes. It looks like direct calls to the API and calls from the Shopify GraphQL app are working when there's only one move, but if I have more than 1, it doesn't update even though there are no errors.

 

Also, I haven't deployed any code changes in over a week and everything has been working fine until right now.

 

So, in other words, this works when there's only one move:

mutation {
  collectionReorderProducts(
    id: "Z2lkOi8vc2hvcGlmeS9Db2xsZWN0aW9uLzMxMjI0MDE0NDU3OQ=="
    moves: [
        {id: "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc0MzUzNTExOTU4NDM=", newPosition: "0"}
    ]
  ) {
    job {
      id
    },
    userErrors {
      message
    }
  }
}

But this does not (when there's more than one move):

 

mutation {
  collectionReorderProducts(
    id: "Z2lkOi8vc2hvcGlmeS9Db2xsZWN0aW9uLzMxMjI0MDE0NDU3OQ=="
    moves: [
        {id: "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc0MzUzNTExOTU4NDM=", newPosition: "0"},
        {id:"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzcxOTQyODI3ODcwMTE=",newPosition:"1"}
    ]
  ) {
    job {
      id
    },
    userErrors {
      message
    }
  }
}

 

Replies 5 (5)

Kris_Doyle
Shopify Partner
140 1 44

Some additional info...I have been able to determine that if I reverse the order of the moves, the mutation works. But if I leave them in order, the mutation fails. 

 

So these moves do not work:

{id:"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc0MzUzNTExOTU4NDM=",newPosition:"0"},
{id:"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzcxOTQyODI3ODcwMTE=",newPosition:"1"}

But this below does work:

 

{id:"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc0MzUzNTExOTU4NDM=",newPosition:"1"}, {id:"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzcxOTQyODI3ODcwMTE=",newPosition:"0"}

 

The only different is the order of the moves. Listing them descending by newPosition works.

 

Unfortunately reversing the order isn't an option since it's baked into a few places. In any case, this seems to be a bug in the API at the moment. By the way, the title is misleading since the direct calls do not work per the notes above. Unfortunately I can't edit it anymore so, yeah 🙂

mattdenoronha
Shopify Partner
35 1 15

Confirming this is an issue we're also experiencing on one of our apps. We've seen reports from other apps as well.

 

We've managed to get it to work with a moves list of less than 11, however this is intermittent. I doubt it makes a difference, but we're using the product gid as the id.

Kris_Doyle
Shopify Partner
140 1 44

Thanks @mattdenoronha , this is still an issue for us at this time. I think Shopify is working on it but I haven't heard any updates yet.

Kris_Doyle
Shopify Partner
140 1 44

By the way, something we've noticed is that if we save the sort order in reverse (i.e. by newPosition descending) then it works. But If we save it ascending with more than 1 product, it doesn't work. Very strange but I'm doing this with just the API, not even the app now.

 

I can reproduce it with both the Shopify GraphQL app and with direct calls to the API.

Kris_Doyle
Shopify Partner
140 1 44

Looks like this issue still exists. The only way I can get the sort call mentioned above to work, is to send the moves in descending order (newPosition descending). If I send the moves with newPosition in ascending order, the call fails with no errors.

 

Can anyone at @Shopify shed some light on this? Is it at all related to the active 500 issue?

 

Thanks very much.