I want to return the name of a publication, this field says it’s deprecated but it returns the right value. Field also says to use Catalog.title instead, doing so I get “catalog”:null. I’m confused, is the documentation incorrect? Am I doing something wrong?
query publications {
publications(first: 3) {
edges {
node {
id
autoPublish
name
catalog {
id
status
title
}
}
}
}
}
publications documentation
1 Like
Hi @pinghajen,
I can confirm that this is expected that the publication.name field is deprecated and the expected way to get the name is from the catalog.title field.
I’m also able to replicate the behaviour you’re experiencing, with publications created via the publicationCreate mutation, not passing the input.catalogId input argument, being created without any associated catalogs.
This leads to the publication.catalog returning null.
I’ve discussed this behaviour our developers further who has confirmed this is expected behaviour at this time.
Even though publications without any associated catalogs don’t actually do anything, this was done by design to allow apps to create publications in advance, then associate a catalog with them at a later time with the catalogUpdate mutation (passing in the publication id in the input). This allows for apps to “stage data” in advance before associating the publications and catalogs together.
If you are creating the publiciations yourself and if you want them to be named, you should associate an existing catalog with them during the publicationCreate mutation.
Otherwise, you can basically ignore publications without any catalogs, as they don’t actually do anything until they do have a catalog associated with them.
I’ll be submitting some feedback on your behalf to our developers internally, as this is a confusing workflow, especially when a publication needs a catalog associated with it to actually do anything on the storefront, I’ll be recommending that the publicationCreate mutation should have the input.catalogId as a required input field, and the mutation should fail if a valid catalog is not included.
For more information on how Catalogs and Publications work, you can refer to our Shopify.dev documentation:
Maybe I’m not understanding but I have the products added to Shopify but I need to add them to my online store sales channel and don’t want to use a deprecated field to be able to get the name of the channel.
Hi @pinghajen I can confirm that the catalog.title would be the correct field to get the catalog associated with the Online Store channel.
Basically this boils down to the following:
-
Publications represent a group of products or collections
-
Publications must have an associated Catalog, Publications with no associated Catalogs have no use, but it is possible to create them without a Catalog associated via the API, and add an associated Catalog later with the catalogUpdate mutation.
-
Catalogs can be associated with an App, Market, or B2B Company Location that you want to publish products to, via the objects on the Catalog interface; AppCatalog, MarketCatalog, and CompanyLocationCatalog
If you are wanting to publish products to your online store via the API, you can do so with the following workflow:
-
Get the Catalog and Publication ID for the Online Store Channel, this can be done with a catalogs query like so:
{
catalogs(first:20, type: APP, query:"title:Online Store"){
nodes{
__typename
id
title
publication{
id
}
}
}
}
-
With the Publication ID associated with the Online Store Catalog, you can then use the publishablePublish mutation to add specific products to this publication and publish them to the Online Store Sales Channel.
Mutation:
mutation publishablePublish($id: ID!, $publicationId: ID!) {
publishablePublish(id: $id, input: {publicationId: $publicationId}) {
publishable {
publishedOnPublication(publicationId: $publicationId)
availablePublicationsCount {
count
}
resourcePublicationsCount {
count
}
}
shop {
publicationCount
}
userErrors {
field
message
}
}
}
Variables:
{
"id": "gid://shopify/Product/12345678910",
"publicationId": "gid://shopify/Publication/12345678910"
}
Hi @pinghajen,
I just wanted to follow up here and see if this answered all your questions? If so we can go ahead and solve this thread, otherwise I’m happy to help with any further questions!