PublishablePublish in bulk after productCreate

PublishablePublish in bulk after productCreate

lvorraro
Shopify Partner
7 0 10

HI everyone,

 

I use the GraphQL Admin API to send products and receive orders.

I create thousands of products at time via bulk operation "createProducts". 

My current problem is the field "published" has been remove from ProductInput

and now I need to call the mutation "publishablePublish" for each product.

 

This is ridiculous, I have a  cloud application with many sellers integrated with Shopify and every seller now need to call "publishablePublish" for every single product, the result will be billions of calls?


Please, does anyone have the same problem as me?

 

Help please

Replies 9 (9)

batsandi
Shopify Partner
3 0 0

Did you find a solution? I am integrating a legacy store and basically need to delete and create all products every day to reflect inventory...

1. I need to delete all products by product ID one by one

2. I bulk upload all products with bulkOperationRunMutation productCreate (which in it of itself is overly complex with its staging and multiple calls and polling to check the status etc.)

3. ImageSrc is now deprecated, so i need to run productCreateMedia for every single product to upload an image

4. And now... I need to run publishablePublish on all products???

 

I thought the idea of the GraphQL admin API was to limit the number of calls necessary to acheive certain tasks - doesn't seem to acheive that goal...

guest4
Shopify Partner
101 7 24

@lvorraro It's now available via bulk operations:

https://shopify.dev/docs/api/usage/bulk-operations/imports#limitations

 

@batsandi The thoughts and feelings that you're expressing are similar to the ones that we've had while trying to get things done with the API. We've had to build several new systems in response to changes with the API. That can take the wind out of our sails.

 

Here are a couple of reassuring ideas that we've had:

  • We've seen that when there's an aspect of the API that seems inconsistent with how it should be used, it will eventually be resolved (like in this case). This tends to be little or no help at the time, but the prospects of it help set internal/external expectations.

  • The documentation tends to lag behind the actual system, so it may be worth trying something, even if the documentation doesn't support the idea. This tends to be the case less and less (and that's probably a good thing). Example: https://community.shopify.com/c/graphql-basics-and/how-perform-bulk-publication-of-products-and-coll...

  • The Shopify API team's understanding of information system architecture is mighty. It's impressive how the system components and their interactions are deconstructed.

  • Finally, adapting to the change tends to result in systems that are better designed for us. The systems that we've built in response to the API changes aren't just band-aids; they're dynamic and resilient responses to the change.

    For example, we've built a "store tasks" system which takes a task type as input (bulk operation type or internally defined type), gets all of the data for the task group (from Shopify or from internal systems), segments it into tasks (to accommodate usage limitations), runs the bulk operations (or internal functions), and then polls for completion if a task is asynchronous. 
athosdigital
Shopify Partner
3 1 4

I'm probably missing something, but the bulk upload method is still incredibly annoying. If I want to remove some publications and add some others, I still need to make two bulk operations right? It seems there is no simple way to update a products publications (sales channels) in bulk using 1 mutation call..

 

I've been bashing on `publicationUpdate` for a few hours today as I thought this would be the silver bullet because it had `publishablesToAdd` and `publishablesToRemove`. However, this is the other way around. So you specify a publishable ID and add/remove products from that publishable. 

den232
Shopify Partner
213 8 55

As of june 2024, an array works:

 

mutation publishablePublish($id: ID!, $input: [PublicationInput!]!) {
  publishablePublish(id: $id, input: $input) {
    publishable {
      availablePublicationsCount {
        count
      }
      resourcePublicationsCount {
        count
      }
    }
    shop {
      publicationCount
    }
    userErrors {
      field
      message
    }
  }
}
 
YES!  As of June 2024, publicationId can be an array, like this:
 
 
 
{
"id": "gid://shopify/Product/11111111",
"input": [
 
{"publicationId": "gid://shopify/Publication/2222222"},
 
{"publicationId": "gid://shopify/Publication/3333333"},
 
{"publicationId": "gid://shopify/Publication/4444444"}
 
]
}
wonena-dev
Shopify Partner
21 0 7

HI Could you please explain with an example how this particular array works? Im getting familiar with the mutation Payload Returns

Building a Sustainable Marketplace from Scratch
guest4
Shopify Partner
101 7 24

It is annoying to work with some aspects of the API, but it gets better as time goes. 

 

We've built an entire system for working with the bulk operations: Getting data, transforming it, acting on it in groups of tasks and organized by types. We don't call it "bulk operation system" though, because it's vendor agnostic and lends itself to work on other systems. It took some time up front, but it has paid off in the long run. 

wonena-dev
Shopify Partner
21 0 7

Out of curiosity: Do you use the mutation space to include this code? Or where do you run it? 

I only use the mutation fields, and I find that the following structure is unfamiliar with the space provided because the space is usually already inside the mutation. So, when additional fields are included, the mutation usually excludes them. So far, I haven't solved this issue.

 

mutation publishablePublish($id: ID!, $input: [PublicationInput!]!) {
  publishablePublish(id: $id, input: $input) {\
Building a Sustainable Marketplace from Scratch
den232
Shopify Partner
213 8 55

Sorry, I don't understand your question. Can you use different words?  What is a mutation space?   Cheers jb

guest4
Shopify Partner
101 7 24

To this point, the following are now available for use with Bulk Operations:

See also: https://shopify.dev/docs/api/usage/bulk-operations/imports