location Deletemutation
mutation
2024-10latest
Requires write
access scope.
Deletes a location.
Arguments
The ID of a location to delete.
Was this section helpful?
LocationDeletePayload returns
Anchor to LocationDeletePayload.deletedLocationIddeletedLocation Id The ID of the location that was deleted.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Code examples for MUTATION: locationDelete
Query Reference for MUTATION: locationDelete
"mutation locationDelete($locationId: ID!) {\n locationDelete(locationId: $locationId) {\n deletedLocationId\n locationDeleteUserErrors {\n # LocationDeleteUserError fields\n }\n }\n}"
Input Reference for MUTATION: locationDelete
"{\n \"locationId\": \"gid://shopify/<objectName>/10079785100\"\n}"
Schema Reference for MUTATION: locationDelete
""
Display Examples for MUTATION: locationDelete
[ { "example": { "type_name": "locationdelete", "title": "Delete a location and return the location ID", "description": "Delete a location that has been deactivated.", "query_string": "mutation {\n locationDelete(locationId: \"gid://shopify/Location/658095763\") {\n deletedLocationId\n }\n}", "query_arguments": { "locationId": "gid://shopify/Location/658095763" }, "response": { "data": { "locationDelete": { "deletedLocationId": "gid://shopify/Location/658095763" } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/shop_identity/test/unit/graph_api/admin/mutations/location_delete_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation { locationDelete(locationId: \\\"gid://shopify/Location/658095763\\\") { deletedLocationId } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation {\n locationDelete(locationId: \"gid://shopify/Location/658095763\") {\n deletedLocationId\n }\n }`,\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation {\n locationDelete(locationId: \"gid://shopify/Location/658095763\") {\n deletedLocationId\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `mutation {\n locationDelete(locationId: \"gid://shopify/Location/658095763\") {\n deletedLocationId\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation {\n locationDelete(locationId: \"gid://shopify/Location/658095763\") {\n deletedLocationId\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [] }, { "example": { "type_name": "locationdelete", "title": "Delete an active location", "description": "Deleting an active location returns an error.", "query_string": "mutation {\n locationDelete(locationId: \"gid://shopify/Location/658095763\") {\n deletedLocationId\n locationDeleteUserErrors {\n message\n code\n field\n }\n }\n}", "query_arguments": { "locationId": "gid://shopify/Location/658095763" }, "response": { "data": { "locationDelete": { "deletedLocationId": null, "locationDeleteUserErrors": [ { "message": "The location cannot be deleted while it is active.", "code": "LOCATION_IS_ACTIVE", "field": [ "locationId" ] } ] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/shop_identity/test/unit/graph_api/admin/mutations/location_delete_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation { locationDelete(locationId: \\\"gid://shopify/Location/658095763\\\") { deletedLocationId locationDeleteUserErrors { message code field } } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation {\n locationDelete(locationId: \"gid://shopify/Location/658095763\") {\n deletedLocationId\n locationDeleteUserErrors {\n message\n code\n field\n }\n }\n }`,\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation {\n locationDelete(locationId: \"gid://shopify/Location/658095763\") {\n deletedLocationId\n locationDeleteUserErrors {\n message\n code\n field\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `mutation {\n locationDelete(locationId: \"gid://shopify/Location/658095763\") {\n deletedLocationId\n locationDeleteUserErrors {\n message\n code\n field\n }\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation {\n locationDelete(locationId: \"gid://shopify/Location/658095763\") {\n deletedLocationId\n locationDeleteUserErrors {\n message\n code\n field\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [] } ]