Bulk operations for delivery profiles with variants not working

Osamaklabs
New Member
3 0 1

i want delivery profiles with profile items (including variants and product) using bulk operations

mutation {
                bulkOperationRunQuery(
                 query: """
                 {
                    deliveryProfiles {
                        edges {
                            node {
                                id
                                name
                                default
                                profileItems {
                                    edges {
                                        node {
                                            product {
                                                id
                                                handle
                                              }
                                            variants {
                                                edges {
                                                  node {
                                                    id
                                                    title
                                                  }
                                                }
                                              }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                  """
                ) {
                  bulkOperation {
                    id
                    status
                  }
                  userErrors {
                    field
                    message
                  }
                }
              }

 its return error:
The parent 'node' field for a nested connection must select the 'id' field. Connection fields without 'id': profileItems.
if i add id in profileItems node then its give error:
Invalid bulk query: Field 'id' doesn't exist on type 'DeliveryProfileItem'

please help

Replies 9 (9)
L_J_K
Shopify Staff
Shopify Staff
400 64 81

Hey @Osamaklabs 

Thanks very much for raising this. We'd deployed a fix recently that should resolve this. 

Let me know if you're still stuck at all. Thanks!

| Shopify |
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
HPrince
New Member
4 0 0

Hey,

 

I'm using 2021-10 and even tried 2022-01 and the unstable versions. Still getting this error. Could you please know what version this was fixed in?

L_J_K
Shopify Staff
Shopify Staff
400 64 81

Hey @HPrince 

That's strange, as the ability to run bulk queries of Profile Item's within a Delivery Profiles query was included as an API change since 2021-10. Are you having trouble with the DeliveryProfileItem ID?

If you're running into issue with this would you mind sharing the query you are making and the x-request-id from the headers if possible? We'll be able to take a look and investigate what's happening. Thanks!

| Shopify |
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
HPrince
New Member
4 0 0

 

I'm currently testing this within Shopify GraphiQL App.

I can run this query just fine.

 

 

 

{
  deliveryProfile(id: "gid://shopify/DeliveryProfile/48711893091") {
    name
    profileItems(first: 5) {
      edges {
        node {
          variants(first: 5) {
            edges {
              node {
                id
                product {
                  handle
                }
              }
            }
          }
        }
      }
    }
  }
}

 

 

 

 

Following your guide here, I came up with this  

 

 

 

mutation {
  
bulkOperationRunQuery(
    
query:"""
    
{
  deliveryProfile(id: "gid://shopify/DeliveryProfile/48711893091") {
    name
    profileItems {
      edges {
        node {
          variants {
            edges {
              node {
                id
                product {
                  handle
                }
              }
            }
          }
        }
      }
    }
  }
}


"""
  
) {
    
bulkOperation {
      
id
      
status
    
}
    
userErrors {
      
field
      
message
    
}
  
}
}





 

 

 

 

It still gives me OPs error. See screenshot below!

Screen Shot 2021-10-06 at 3.16.54 pm.png

 
Updating Media

 

L_J_K
Shopify Staff
Shopify Staff
400 64 81

Hey @HPrince 

Apologies for the delayed response here and thanks for supplying that!

Seems you're missing the ID from the ProfileItems and first when you run the query from your screenshot against the Unstable GraphQL API. Something like this below will successfully create a Bulk Operation Run Query Successfully.

 

mutation {
  bulkOperationRunQuery(query: """
    {
  deliveryProfile(id:"gid:\/\/shopify\/DeliveryProfile\/{Delivery_Profile_ID}") {
     name
    profileItems(first: 5) {
      edges {
        node {
          id
          variants(first: 5) {
            edges {
              node {
                id
                product {
                  handle
                }
              }
            }
          }
        }
      }
    }
  }
}
  """) {
    bulkOperation {
      id
      status
    }
    userErrors {
      field
      message
    }
  }
}

 

If I take your first query above there, you'll note that has the first arguments supplied, it would run successfully.

One other thing is that I don't rightly see why we wouldn't expose the DeliveryProfileItem ID on versions other than unstable - that seems to be an oversight, we'll look into that.

It's worth noting too, that we have a new Webhook in 2021-10 - bulk_operations/finish -  it would notify you when the bulk operation completes. Hope that helps!

 

| Shopify |
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
HPrince
New Member
4 0 0

Ah I didn't realise we had to supply the first/last argument in a bulk query.  Could you please confirm that this query will generate all items and not just the first couple?

I did do a test run and it gave me a lot more than 5 but does it include all delivery profile items?

L_J_K
Shopify Staff
Shopify Staff
400 64 81

Hey @HPrince 

So, on my query directly to the delivery Profile ID taking that query above for example, the (first: 5) argument on the profileItems is going to return me up to the first 5 Delivery profile items that belong to my delivery profile ID, along with up to the (first: 5) variants that are belong to the ProfileItems. 

If there's less than 5 profileitems/variants on either of those connections(the links between related objects), they will just be returned regardless. If there's more than 5, they wouldn't be returned. 

The reason for the use of the argument is that it's a GraphQL convention - when connections are used, the number of objects you want returned (either first or last in the set) would need to be specified. Hope that helps!

 

 

| Shopify |
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
HPrince
New Member
4 0 0

Hello,

Thanks for this. 

So is there a way I can export all the variants associated to a Delivery Profile?

Osamaklabs
New Member
3 0 1

i think we cant do this in current apis
we need this, shopify should have to add these type of query in bulk operations
i am also facing this in discount bulk query operations with collections.