A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
When publishing a product to the online store I get the following error:
Hi Wakil,
Are you using the storefront API?
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
At 1st I was using the admin API but now I'm using the storefront API and still no luck.
This following code is getting executed in the action:
const { admin } = await authenticate.admin(request);
const { storefront } = await unauthenticated.storefront( 'test-app.myshopify.com' );
// Publish the product.
// const publishProductRequest = await admin.graphql(
const publishProductRequest = await storefront.graphql(
`#graphql
mutation publishProduct($id: ID!, $input: [PublicationInput!]!) {
publishablePublish(id: $id, input: $input) {
userErrors {
field
message
}
publishable {
availablePublicationCount
publicationCount
publishedOnCurrentPublication
}
shop {
id
name
publicationCount
}
}
}`,
{
variables: {
id: productId,
input: {
publicationId: onlineStorePublicationId,
},
},
}
);
const publishProductResponse = await publishProductRequest.json();
return json(publishProductResponse);