Problems using draftOrderUpdate mutation

Topic summary

Problem: draftOrderUpdate returned “invalid id.” The OP suspected the draft order ID format (plain GID vs base64) was the cause.

Diagnosis and fix: The error stemmed from lineItems.variantId using a Product ID instead of a ProductVariant ID. Correct format is gid://shopify/ProductVariant/, not gid://shopify/Product/. After switching to a variant ID, the mutation succeeded.

Clarifications: The base64 vs GID string concern was not the issue; the core problem was the variantId type. A Shopify rep acknowledged the error messaging could be more specific to aid debugging.

Follow-up case: A second user shared a failing mutation that appears structurally correct. A Shopify staffer advised including userErrors { field message } in the response and checking the current docs to surface the specific validation errors. No final resolution was posted for this case.

Status: Original issue resolved; later inquiry remains open pending error details.

Notes: Code snippets (mutation, variables) are central to understanding; no images or attachments mentioned.

Summarized with AI on January 12. AI used: gpt-5.

Hi there,

I can’t work out whether this is a problem on my end (i.e. am I using the wrong ID) or if this is a bug with Shopify.

I have a draft order and I want to update it with the Shopify Admin GraphQL API as per https://shopify.dev/docs/admin-api/graphql/reference/orders/draftorderupdate#draftorderinput-fields-2021-01

I have a payload which I am passing into the input (note that this is a reduced version of what I am actually sending, but this should still work).

Mutation:

mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {
  draftOrderUpdate(id: $id, input: $input) {
    draftOrder {
      id
    }
    userErrors {
      field
      message
    }
  }
}

Variables:

{
  "id": "gid://shopify/DraftOrder/738221752504",
  "input": {
    "email": "joe@bloggs.com",
    "customerId": "customer-id-here",
    "lineItems": [
      {
        "quantity": 1,
        "variantId": "gid://shopify/Product/6186305716408"
      }
    ],
    "customAttributes": []
  }
}

However, when I try to run this mutation (either in my code or within the Insomnia API tool) I am getting this error:

{
  "data": {
    "draftOrderUpdate": null
  },
  "errors": [
    {
      "message": "invalid id",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [ "draftOrderUpdate"
      ]
    }
  ]
}

I’m completely at a loss. The only difference (between the payload I am sending and the Shopify example) that I could find was that the format of the order ID is different. See below:

My ID:

gid://shopify/DraftOrder/738221752504

Example ID from link posted earlier:

Z2lkOi8vU2hvcGlmeS9FeGFtcGxlLzE=

The example ID appears to be a base64 string, I decoded this and got:

gid://Shopify/Example/1

So, to rule this out, I also tried encoding my ID as a base64 string and received the same error.

Has anyone else experienced this issue? This functionality is pretty key to the app that I’m developing so I’m in a bit of a situation without this mutation!

Any help would be really appreciated.

Thanks!

Can someone from Shopify at least advise the best way to raise this as a possible bug and that the documentation is potentially showing incorrect information?

Hi @Jamie_StackUp ,

I believe the error originates from the variantId of your variable. You’ve indicated a product id which is not what the field is expecting. You should be using “gid://shopify/ProductVariant” instead of “gid://shopify/Product”.

Hopefully this helps resolve the error you’re getting. Let me know if you have any more questions on this.

Best,
Seth.

2 Likes

Hi Seth, thank you so much for getting back to me.

I’ll have a look at this in the morning but yes, I agree, now you’ve pointed that out it’s clear as day!

I’ll report back tomorrow and accept the answer if this works.

Thank you again!

Hey @syf_1 you’ve hit the nail on the head there, that was certainly the problem.

Thanks for clearing it up and I’m sorry for taking up your time with my mistake!

Hey @Jamie_StackUp ,

I’m glad the mutation is working as expected for you, and it was my pleasure to be of help. I do admit though that our error messages could be more specific, and if they were it would have helped you in debugging and identifying the cause of the error.

All the best as you continue to use our developer products!

Seth.

I am trying to run this mutation but it’s not working, can you let me know what am I doing wrong?

mutation {
draftOrderUpdate(
id: “gid://shopify/DraftOrder/1140887388443”
input: {
email: “joe@bloggs.com”,
lineItems: [
{
variantId: “gid://shopify/ProductVariant/47204229939483”,
quantity: 1
}
]
}
) {
draftOrder {
id
}
}
}

Hey @bilal87 ,

I don’t see anything in your mutation that stands out as an issue. I’d recommend looking in to any errors that were returned as that would give you more clarity.

Adding in the user errors in your response can help:

userErrors {> field> message> }

You can also consult our documentation here for more clarity on these mutations - https://shopify.dev/docs/api/admin-graphql/2023-10/mutations/draftOrderUpdate#top

Hope that helps,

  • Kyle G.