What's your biggest current challenge? Have your say in Community Polls along the right column.
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.

Publish products via GraphQL Admin API

Publish products via GraphQL Admin API

samwise
Shopify Partner
31 0 6

Hi there, 

 

I am having trouble to publish/unpublish product via GraphQL. Per this doc:

https://help.shopify.com/en/api/graphql-admin-api/reference/mutation/productupdate

 

published   (Boolean)
This argument is deprecated: Use PublishablePublish instead.

 is deprecated. 

 

However, if I follow this doc: https://help.shopify.com/en/api/graphql-admin-api/reference/mutation/publishablepublish

 

1. I do not see this scope available - https://help.shopify.com/en/api/getting-started/authentication/oauth/scopes 

write_publications access scope

 

2.  Also, PublicationInput seems to need a channelID.  It seems it is another pain. 

 

Am I following right? Or there is some other way to do via GraphQL API?  Otherwise, I am ok on REST just want to understand.  Thank you so much!

 

 

Replies 12 (12)

evladimir
Shopify Partner
2 0 3

Did you find a solution? Many people have this issue

I can't publish a product or collection to "Online store" channel, which is pretty trivial use-case. They just created as "unavailable".

 

samwise
Shopify Partner
31 0 6

Went via REST.

Yu727
Excursionist
38 0 10

Still not possible using GraphQL Admin API?

azacs
Shopify Partner
9 0 20

@evladimir wrote:

Did you find a solution? Many people have this issue

I can't publish a product or collection to "Online store" channel, which is pretty trivial use-case. They just created as "unavailable".

 


Seems the simplest way is:

productCreate(input: {
            title: "Green Tea Ginger Twist",
            productType: "test",
            published: true,
}
)

There's so much ambiguous crap and deception about what is actually functional in the docs that I've spent about an hour and half sorting this out.

 

seandkendall
Tourist
8 0 14

The problem with "published: true" is that it only publishes for "online store" which is usually not the only intent

tehcon
Tourist
3 0 1

@azacs wrote:

@evladimir wrote:

Did you find a solution? Many people have this issue

I can't publish a product or collection to "Online store" channel, which is pretty trivial use-case. They just created as "unavailable".

 


Seems the simplest way is:

productCreate(input: {
            title: "Green Tea Ginger Twist",
            productType: "test",
            published: true,
}
)

There's so much ambiguous crap and deception about what is actually functional in the docs that I've spent about an hour and half sorting this out.

 


But the "published" field is marked as deprecated in latest api version 2020-04 

azacs
Shopify Partner
9 0 20

Looking through the forum it seems it's been depreciated for years.

It's a tragedy, but there's no other option with open graph.

jam_chan
Shopify Partner
927 23 190

@tehcon 

"published" is marked as deprecated on GraphQL API but not on Rest Admin API (Search 'Create a new unpublished product')

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview

BugShallNotPass
Shopify Partner
32 1 10

 

That's a shame that's there are no any comments and suggestions from Shopify on a preferred approach.

 

So one of the methods is deprecated, the other one is only available for private apps on Plus stores, and the last one is to use REST instead of promoted GraphQL. So if you built an app that uses GraphQL all over, but now to publish a product you would also need to incorporate a REST call...

 

No words...

Xmas Shopify app - beautiful falling snow animation
New Arrivals Shopify app - automatically tag/untag products based on creation/publishing date
Motion - scrolling text announcements
Best Sellers Shopify app - and automate bestseller collections based on quantities or sales
Stash Shopify app - hide products from search results and search engines

Tsredi
Shopify Partner
12 1 6

publishablePublish mutation works  now, write_publications & read_publications scopes has been added

javl
Shopify Partner
17 0 15
Any suggestions on how to get the ID for the online store? I can do the following to get a list of publications:

 

 

query publications {
  publications(first: 5) { # getting a limited amount of items is risky
    edges {
      node {
        id
        name # deprecated
      }
    }
  }
}
​

 

But:

 

1. this means I have to be lucky and 'online store' is in the selection as defined by `first` (with the risk of it being item 6 or later and not getting it)
2. `name` is supposedly deprecated and I should use catalog.title instead, but catalog is `null`:
 

 

 

query publications {
  publications(first: 5) {
    edges {
      node {
        id
        catalog { # this is null
          name 
        }
      }
    }
  }
}
​

 

 

 

The deprecated (but still functional way) of just passing `published: true` when creating your new product is so much easier if you just want to publish a product into the Online Store, but of course we're not sure how long this will keep working.
jam_chan
Shopify Partner
927 23 190

You can adjust the number from 5 to a larger one. But I also got the same catalog as null. Not sure why Shopify makes it so complicated.

 

I want my product published on the online store only. But the rest admin API is not reliable. I try to set the published_scope to 'web' and call the productUpdate mutation but it's not working. It gives an error message - Channel Channel XXXX does not support bundle products

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview