Anchor to draftOrderDeletedraft
draftOrderDelete
mutation
Requires access scope. Also: The user must have access to delete draft orders.
Deletes a draft order.
Anchor to Arguments
Arguments
- Anchor to inputinput•Draft
Order requiredDelete Input! Specify the draft order to delete by its ID.
Was this section helpful?
Anchor to DraftOrderDeletePayload returnsDraftOrderDeletePayload returns
- Anchor to deletedIddeleted•
Id The ID of the deleted draft order.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
Was this section helpful?
- Delete a draft order by ID and return the deleted ID
- Deleting a draft order that doesn't exist returns an error
- Remove an existing DraftOrder
- draftOrderDelete reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation draftOrderDelete($input: DraftOrderDeleteInput!) {
draftOrderDelete(input: $input) {
deletedId
}
}`,
{
variables: {
"input": {
"id": "gid://shopify/DraftOrder/276395349"
}
},
},
);
const data = await response.json();
mutation draftOrderDelete($input: DraftOrderDeleteInput!) {
draftOrderDelete(input: $input) {
deletedId
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation draftOrderDelete($input: DraftOrderDeleteInput!) { draftOrderDelete(input: $input) { deletedId } }",
"variables": {
"input": {
"id": "gid://shopify/DraftOrder/276395349"
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation draftOrderDelete($input: DraftOrderDeleteInput!) {
draftOrderDelete(input: $input) {
deletedId
}
}`,
{
variables: {
"input": {
"id": "gid://shopify/DraftOrder/276395349"
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation draftOrderDelete($input: DraftOrderDeleteInput!) {
draftOrderDelete(input: $input) {
deletedId
}
}`,
"variables": {
"input": {
"id": "gid://shopify/DraftOrder/276395349"
}
},
},
});
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 draftOrderDelete($input: DraftOrderDeleteInput!) {
draftOrderDelete(input: $input) {
deletedId
}
}
QUERY
variables = {
"input": {
"id": "gid://shopify/DraftOrder/276395349"
}
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"input": {
"id": "gid://shopify/DraftOrder/276395349"
}
}
Response
JSON{
"draftOrderDelete": {
"deletedId": "gid://shopify/DraftOrder/276395349"
}
}