A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
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:
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!
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:
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.
If I open a product's page on the admin interface, then I see this "publications" box:
There are two menu points available, "manage sales channels" and "manage markets":
If I choose "manage markets" then a dialog with checkboxes comes up:
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.