How to retrieve all delivery profile items - DeliveryProfileItem node has no "id" field

simonhaenisch
Tourist
4 0 2

I'm using the shipping_zones.json Admin REST API endpoint to get a list of all configured shipping zones and their rates so that I can determine the shipping cost per product variant.

This works fine for the default shipping zones, however the shop I'm working with also has custom shipping zones (I believe these are called delivery profiles now), that some products are assigned to. With the GraphQL API I can get the products that are assigned:

 

query deliveryProfile {
  deliveryProfile(id: "gid://shopify/DeliveryProfile/123456789") {
    default
    profileItems(first: 250) {
      edges {
        node { 
        	product {
            id
          }
        }
      }
    }
  }
}

 

 

However this query is quite inefficient (query cost of ~500), and allows me to get max 250 items at a time. Anyway, if I also want to get all of the profile item's variant ids, this query becomes impossible cost-wise.

So I thought I could use a bulk operation for this, but turns out that's not possible because DeliveryProfileItem has no "id" field and without it I can't write the bulk query:

 

{
  deliveryProfiles {
    edges {
      node {
        id
        default
        profileItems {
          edges {
            node {
              // no id field exists here
              product {
                id
              }
              variants {
                edges {
                  node {
                    id
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

 

 

The parent 'node' field for a nested connection must select the 'id' field. Connection fields without 'id': profileItems.

(see https://shopify.dev/docs/admin-api/graphql/reference/shipping-and-fulfillment/deliveryprofileitem)

 

TBH it seems like this is something that would be relatively straightforward if a REST API endpoint was exposed for this, but the GraphQL API makes it pretty expensive to do this. So now I'm wondering how to solve this... is it actually something that could be considered a bug, that the DeliveryProfileItem node id is not exposed?

0 Likes
zubairmohsin
Shopify Partner
57 1 10

Hey, did you find a solution to this? Or did you go with another approach?

0 Likes