Re: Cannot query market publication status for product ( publishedOnPublication ) via graphql

Cannot query market publication status for product ( publishedOnPublication ) via graphql

imagella
Excursionist
12 0 5

Taken from the graphql documentation, this call works:

 

{
product(id: "gid://shopify/Product/8483815850262") {
publishedInCA: publishedInContext(context: {country: CA})
}
}

But this does not:

 

{
product(id: "gid://shopify/Product/8483815850262") {
publishedOnPublication(publicationId: "gid://shopify/Market/84247544086")
}
}

The second one throws this error:

{
  "errors": [
    {
      "message": "invalid id",
      "locations": [
        {
          "line": 3,
          "column": 6
        }
      ],
      "path": [
        "product",
        "publishedOnPublication"
      ]
    }
  ],
  "data": {
    "product": null
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 1,
      "actualQueryCost": 1,
      "throttleStatus": {
        "maximumAvailable": 2000,
        "currentlyAvailable": 1999,
        "restoreRate": 100
      }
    }
  }
}

They are both documented here: 

 

https://shopify.dev/docs/api/admin-graphql/2024-07/queries/product?example=Query+whether+a+product+i...

 

The publishedInContext and publishedOnPublication fields are almost identical. They are boot non-null booleans. The only difference is their arguments ( https://shopify.dev/docs/api/admin-graphql/2024-07/input-objects/ContextualPublicationContext vs https://shopify.dev/docs/api/admin-graphql/2024-07/scalars/ID )

 

I fail to understand why the first one works, and the second one doesn't.

 

Please help me!

Replies 2 (2)

imagella
Excursionist
12 0 5

I found out that the "invalid id" errors comes back because the provided id is a market:

"gid://shopify/Market/84247544086"

but it should be a Publication instead.

 

I'm very confused about the meaning of "Publication", and the difference between a "Channel", a "Market" and a "Publication".

 

In fact, most fields called "channel" are deprecated in 2024-07, and they always refer to "publication" as the preferred alternative.

 

Examples:

 

imagella_0-1724523620985.png

 

But the channelId argument has type `ID!` and there is nothing said about what kind of id that should be. So, a channel ID is an ID, but a publication ID and a channel ID could be two different things. It is impossible to tell them apart from the documentation (at least I could not find it). Formally, the ID can be the ID of anything.

 

Very similar with https://shopify.dev/docs/api/admin-graphql/2024-07/mutations/productPublish and https://shopify.dev/docs/api/admin-graphql/2024-07/mutations/productUnpublish , their arguments are publication ids, and probably they are different from market ids.

 

Now I think that market ids and publication ids are very different things: a publication id is the identifier of a product - market pair (I'm just guessing).

 

What I really want to know is this:

 

* how can I query the markets that are assigned to a single products?

* how can I assign / deassign a market with a product?

 

First I thought that publishedOnPublication, productPublish and productUnpublish are the right API calls for this. But I'm not so sure anymore.

imagella
Excursionist
12 0 5

If I open a product's page on the admin interface, then I see this "publications" box:

 

imagella_0-1724525552051.png

 

There are two menu points available, "manage sales channels" and "manage markets":

imagella_1-1724525587112.png

 

If I choose "manage markets" then a dialog with checkboxes comes up:

imagella_2-1724525645178.png

I seem to be able to enable/disable markets for individual products. So I guess, there should be an API to query and modify this data?

 

I feel like I'm totally wrong, not seeing the forest from the tree.