A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hi there i have installed shopify-graphiql-app and trying to run a mutation, not sure why I am getting this error, can anyone help here, thanks.
mutation { orderEditAddCustomItem(id: "gid://shopify/Order/4413610786973", price: {amount: 300.00, currencyCode: USD}, quantity: 1, title: "MY CUSTOM THINGS") { calculatedLineItem { id } calculatedOrder { id } userErrors { field message } } }
"errors": [ { "message": "invalid id", "locations": [ { "line": 2, "column": 3 } ], "path": [ "orderEditAddCustomItem" ] } ],
Please remember I have used all the required scopes.
Solved! Go to the solution
This is an accepted solution.
hey, I got success If someone else is looking for this.
So here are the steps.
you need to have write_order_edits rights via scope when getting auth access token.
then you need to pass global order id of graphql mutation
first call mutation orderEditBegi
it will return calculated order id
then pass that calcualted order id into
mutation orderEditAddCustomIte
then at the end do call orderEditCommit with the same calcuated order id
and thats it, thanks.
Hi @Kornemann ,
the id refers to a Calculated Order , see https://shopify.dev/api/admin-graphql/2022-01/objects/CalculatedOrder, so the ID should somehow like gid://shopify/CalculatedOrder/1832681575.
Have you seen the discussion here ?
Regards
Thomas
Hey @tewe thanks for getting back,
For now we have two ids, one `shopify_order_id` and other is `admin_graphql_api_id`
so you are saying in mutation
```orderEditAddCustomItem(id: "gid://shopify/Order/44136107xxxxx", price: {amount: 300.00, currencyCode: USD}, quantity: 1, title: "MY CUSTOM THINGS") {```
I need to pass calculated order id?
if that is the case, then from where I can find that calculated order id.
All I need to do is to add a custom line item in the order.
can you please tell all the steps?
moreover @tewe when i try to begin order edit with following mutation, I am getting calculated order id null.
mutation is
mutation {
orderEditBegin(id: "gid://shopify/Order/44136107xxxx") {
calculatedOrder {
id
}
}
}
and response is
{
"data": {
"orderEditBegin": {
"calculatedOrder": null
}
},
"extensions": {
"cost": {
"requestedQueryCost": 10,
"actualQueryCost": 10
}
}
}
This is an accepted solution.
hey, I got success If someone else is looking for this.
So here are the steps.
you need to have write_order_edits rights via scope when getting auth access token.
then you need to pass global order id of graphql mutation
first call mutation orderEditBegi
it will return calculated order id
then pass that calcualted order id into
mutation orderEditAddCustomIte
then at the end do call orderEditCommit with the same calcuated order id
and thats it, thanks.
Bonus points if you can figure out a way to do this from shopify flow where to my knowledge there is no way to currently assign a variable for use in another action...thoughts?