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.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Re: fulfillmentServiceDelete does not delete anything

fulfillmentServiceDelete does not delete anything

STN
Shopify Partner
2 0 0

Hello,

 

I created the fulfillmentService and when I query it by ID it works fine.

 

Create Query

 

var fulfillmentServiceCreateRequest = new GraphQLRequest {
    Query = @"
                mutation fulfillmentServiceCreate($name: String!, $callbackUrl: URL!) {
                  fulfillmentServiceCreate(name: $name, callbackUrl: $callbackUrl) {
                    fulfillmentService {
                      id
                      serviceName
                      callbackUrl
                      location {
                        id,
                        name
                      }
                    }
                    userErrors {
                      field
                      message
                    }
                  }
                }
           ",
    OperationName = "fulfillmentServiceCreate",
    Variables = new {
        name = "Test Fulfillment Service",
        callbackUrl = "https://shopify.test.com/"
    }
};

Get By ID Response

 

 

{
    "fulfillmentService": {
        "id": "gid://shopify/FulfillmentService/68707713367?id=true",
        "serviceName": "Test Fulfillment Service",
        "callbackUrl": "https://shopify.test.com/"
    }
}

 

 

Then when I try to delete it, I get the default locationId and set it together with fulfillmentServiceId for deletion.

 

 

        var deleteFulfillmentService = new GraphQLRequest
        {
            Query = @"
                        mutation fulfillmentServiceDelete($id: ID!, $destinationLocationId: ID) {
                          fulfillmentServiceDelete(id: $id, destinationLocationId: $destinationLocationId) {
                            deletedId
                            userErrors {
                              field
                              message
                            }
                          }
                        }
             ",
            OperationName = "fulfillmentServiceDelete",
            Variables = new
            {
                id = "gid://shopify/FulfillmentService/68707713367?id=true",
                destinationLocationId = defaultLocation.Id
            }
        };

 

 

In the response I get no errors and no userErrors. deletedId is also null.

 

    "statusCode": 200,
    "data": {
        "fulfillmentServiceDelete": {
            "deletedId": null,
            "userErrors": []
        }
    },
    "errors": null,

 

 

 

So what is happening here? I hardcoded the id, tried with and without this "id=true" query string. Tried to enter invalid Location ID (then I get actual error). Any advice or ideas why it might not work for deletion? There are no pending orders or anything like that, it's an empty store.

Replies 2 (2)

STN
Shopify Partner
2 0 0

I've also added example using simple cURL so it is more testable and understandable. As you can see same thing - nothing gets deleted even tho documentation states it should delete the fulfillmentService.

 

# 1. Create fulfillment service

# Create Fulfillment Service Request

curl -X POST \
https://MY-APP-NAME.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: WORKING-TOKEN' \
-d '{
"query": "mutation fulfillmentServiceCreate($name: String!, $callbackUrl: URL!) { fulfillmentServiceCreate(name: $name, callbackUrl: $callbackUrl) { fulfillmentService { id serviceName callbackUrl, location { id, name } } userErrors { field message } } }",
 "variables": {
    "name": "example_fulfillment_service",
    "callbackUrl": "https://callback.org/"
  }
}'

# Create Fulfillment Service Response

{
   "data":{
      "fulfillmentServiceCreate":{
         "fulfillmentService":{
            "id":"gid://shopify/FulfillmentService/68726325591?id=true",
            "serviceName":"example_fulfillment_service",
            "callbackUrl":"https://callback.org/",
            "location":{
               "id":"gid://shopify/Location/101633786199",
               "name":"example_fulfillment_service"
            }
         },
         "userErrors":[
            
         ]
      }
   },
   "extensions":{
      "cost":{
         "requestedQueryCost":11,
         "actualQueryCost":11,
         "throttleStatus":{
            "maximumAvailable":2000.0,
            "currentlyAvailable":1989,
            "restoreRate":100.0
         }
      }
   }
}

# 2. Get all locations to use different locations on fulfillment service delete

# Get locations request
curl -X POST \
https://MY-APP-NAME.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: WORKING-TOKEN' \
-d '{
"query": "query { locations(first: 5) { edges { node { id name } } } }"
}'

# Get locations response

{
   "data":{
      "locations":{
         "edges":[
            {
               "node":{
                  "id":"gid://shopify/Location/100800364887",
                  "name":"Shop location"
               }
            }
         ]
      }
   },
   "extensions":{
      "cost":{
         "requestedQueryCost":5,
         "actualQueryCost":3,
         "throttleStatus":{
            "maximumAvailable":2000.0,
            "currentlyAvailable":1997,
            "restoreRate":100.0
         }
      }
   }
}

# 3. Delete fulfillment service using location id above

curl -X POST \
https://MY-APP-NAME.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: WORKING-TOKEN' \
-d '{
"query": "mutation fulfillmentServiceDelete($id: ID!, $destinationLocationId: ID) { fulfillmentServiceDelete(id: $id, destinationLocationId: $destinationLocationId) { deletedId userErrors { field message } } }",
 "variables": {
    "destinationLocationId": "gid://shopify/Location/100800364887",
    "id": "gid://shopify/FulfillmentService/68726325591?id=true"
  }
}'

# Response, nothing got deleted

{
  "data":{
     "fulfillmentServiceDelete":{
        "deletedId":null,
        "userErrors":[
        ]
     }
  },
  "extensions":{
     "cost":{
        "requestedQueryCost":10,
        "actualQueryCost":10,
        "throttleStatus":{
           "maximumAvailable":2000.0,
           "currentlyAvailable":1990,
           "restoreRate":100.0
        }
     }
  }
}
brett_single
Shopify Partner
5 0 12

It looks like the id you are getting back for the fulfillment service is "gid://shopify/FulfillmentService/68726325591?id=true". Not sure why "?id=true" is coming back as part of that, but that's not part of the id. If you take that part off then the delete will probably work correctly.