Problem with GraphQl - delete orders using metafieldDelete

Solved
jirnmy
New Member
6 0 0

I received this message when using GraphQL. Could you help please?

{
  "errors": [
    {
      "message": "Internal error. Looks like something went wrong on our end.\nRequest ID: 25ea121b-2774-4772-9e01-f104fa28dbec (include this in support requests).",
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "requestId": "25ea121b-2774-4772-9e01-f104fa28dbec"
      }
    }
  ]
}

 

This is my code, the order Id was taken from the query above

query main {
  orders(first: 5) {
    edges{
      node {
        id
        closed
      }
    }
    pageInfo {
      hasNextPage
    }
  }
}

mutation delorder {
    second: metafieldDelete(input: {
		id: "gid://shopify/Order/2094635679805"
    }) { 
    	userErrors {field message } deletedId 
    }
}

Please notice that with the id encoded in base64, the error is the same

0 Likes
SBD_
Shopify Staff
Shopify Staff
1044 141 185

Hey @jirnmy 

 

The id should be the ID  of the metafield to delete. Have you tried:

 

 

mutation metafieldDelete($input: MetafieldDeleteInput!) {
  metafieldDelete(input: $input) {
    deletedId
    userErrors {
      field
      message
    }
  }
}

{
"input": { "id": "Z2lkOi8vU2hvcGlmeS9FeGFtcGxlLzE=" }
}

 

 

0 Likes
jirnmy
New Member
6 0 0

Hi @SBD_ 

 

Could you take a look at my query please? I first get the IDs from the `main` query. And then use the IDs from that to delete the Meta in `delorder`.

Could you help point out where I'm wrong?

 

Thanks!

0 Likes
SBD_
Shopify Staff
Shopify Staff
1044 141 185

Hey @jirnmy 

 

You'll need the metafield ID, not the order ID. Try something like this:

 

{
  orders(first:1) {
    edges {
      node {
        id
        metafields (first:1) {
          edges {
            node {
              id
            }
          }
        }
      }
    }
  }
}

mutation metafieldDelete($input: MetafieldDeleteInput!) {
  metafieldDelete(input: $input) {
    deletedId
    userErrors {
      field
      message
    }
  }
}

{
  "input": {
    "id": "gid://shopify/Metafield/1234"
  }
}
jirnmy
New Member
6 0 0

@SBD_ Thanks! I understand now.

 

However, the metafield query doesn't give me any Ids? What could be the problem?

 

The order I'm checking has the status of Cancelled. It's displaying the delete button when viewing order's detail.

0 Likes
SBD_
Shopify Staff
Shopify Staff
1044 141 185

What's the order ID?

0 Likes
jirnmy
New Member
6 0 0

Here is the response, please help, thanks!

{
  "data": {
    "orders": {
      "edges": [
        {
          "node": {
            "id": "gid://shopify/Order/2119891517501",
            "metafields": {
              "edges": []
            }
          }
        }
      ]
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 6,
      "actualQueryCost": 5,
      "throttleStatus": {
        "maximumAvailable": 1000,
        "currentlyAvailable": 995,
        "restoreRate": 50
      }
    }
  }
}
0 Likes
SBD_
Shopify Staff
Shopify Staff
1044 141 185

Hey @jirnmy 

 

That order doesn't appear to have any metafields.

0 Likes
jirnmy
New Member
6 0 0

My main purpose is to delete this Order. It is deletable in the Admin panel.

 

I want to delete it with the API. Could you help please?

0 Likes
SBD_
Shopify Staff
Shopify Staff
1044 141 185

This is an accepted solution.

Ah, I misunderstood - I thought you were trying to delete metafields.

 

I can't see an orderDelete mutation, you might need to use the REST API instead.

0 Likes