Events that connect you directly to leaders in commerce and Shopify
Join us Tuesday, June 18th from 11 am to 1 pm ET for a live AMA where our team will answer questions on the new GraphQL Product APIs announced in the 2024-04 stable API release. Hit "Reply" below to ask your questions before June 18th, 2024 and we’ll answer them live, or bring your questions to be answered on the day of.
What to know:
The new GraphQL product APIs that support up to 2,000 variants per product were recently launched in the 2024-04 stable API release, enabling developers to build support for larger and more complex catalogs. Alongside the release of the new GraphQL product APIs, we also announced deprecations of the REST product APIs, as well as several fields within the existing GraphQL product APIs.
This AMA is an opportunity to interact with the developers who built these APIs to get any questions on both the new APIs and associated deprecations answered.
In advance of the session, please review the API documentation on the new GraphQL product APIs, our FAQ and our relevant community discussions.
Rules of engagement:
We’ll do our best to follow up on every question during the event.
Solved! Go to the solution
This is an accepted solution.
The AMA is now closed. Questions asked past this time will be moved to the appropriate community board.
Thank you to everyone who joined us for this AMA, and for all your excellent questions. Even though our time is up our team will continue to post answers to the questions that have already been asked. We will do our best to answer them as soon as possible.
Make sure you subscribe to our Community AMAs board to be notified about any future community events.
👋 Hi @Addrevenue,
Do you have an example of a mutation that you are trying to run that is timing out?
From reading more about your use case I think designing a set of mutations that would allow you to avoid using bulkOperation would be ideal. If you have to do many calls to bulkOperation in sequence it kind of kills the usefulness of that operation.
This store for example: maxigastro-sverige
Here is the payload:
mutation {
bulkOperationRunQuery(
query: """ {
productVariants(first: 999999) {
edges {
node {
id
sku
displayName
price
compareAtPrice
contextualPricing(context: {country: SE}) {
price {
amount
currencyCode
}
compareAtPrice {
amount
currencyCode
}
}
image {
url
}
availableForSale
inventoryQuantity
translations(locale: "sv") {
key
value
}
product {
id
title
descriptionHtml
onlineStoreUrl
onlineStorePreviewUrl
vendor
featuredImage {
url
}
productCategory {
productTaxonomyNode {
fullName
}
}
productType
totalVariants
status
translations(locale: "sv") {
key
value
}
images(first: 1, sortKey: POSITION) {
edges {
node {
url
}
}
}
}
}
}
}
}
"""
) {
bulkOperation {
id
status
}
userErrors {
field
message
}
}
}
And then I poll the id in the response:
{
node(id: "$id") {
... on BulkOperation {
status
url
}
}
}
For some stores it takes maybe 2-3 seconds. For most stores it takes maybe 20-25 seconds. And for a few it surpassed 2 minutes or more.
If there is a better way to get thousands of products in seconds from a single store in a synchronous call, without getting over quota, then I'd love that. Also remember that I will connect to maybe a hundred stores, so every second counts.
Hey folks!
Welcome to our New GraphQL Product APIs AMA. Thank you to everyone who has already posted questions. Our developer team will be going through the questions and providing answers for the next two hours.
Please continue to ask our team questions. We will get to as many as we possibly can.
Thanks for joining us!
Where is the AMA link? I misunderstood and thought this was a video call
I had the same confusion. And it seems many others did too.
Hi Shopify developers,
I checked the new ProductSet mutation api, it's very important for us to export the product from ERP to Shopify store, but I found that the input fields under the variant level are less than the fields in the ProductVariantCreate API, it doesn't include the inventoryItemInput in the ProductSet api, that means we cannot use ProductSet API to publish all data once, we have to call 2 or more APIs to create/update product and vairants. Do you have a plan to include these fields in the ProductSet API as well?
Hi @Simon_Liang
We have heard feedback from lots of partners that this is something they would consider very helpful. We are currently looking into the best way to allow inventory to work with ProductSet.
We were initially concerned that including too much scope into ProductSet would impact our ability to give a satisfactory level of performance in the API. As we continue to improve things we believe that this concern will no longer be relevant.
I see that all public apps need to migrate from the deprecated APIs by Feb 1, 2025.
Q1. Is this the final deadline? Or should we expect any changes to this?
Q2. Will there be any code approvals or any formal reviews needed? Or can we just update as per the usual code deployment processes?
Hi @sunnyLA ,
1. The answer here depends on if you are asking for a public or a custom app: https://shopify.dev/changelog/deprecation-timelines-related-to-new-graphql-product-apis. Let us know if there is a further question for either
2. You can just update your codebase 🙂
Can we ask about all of shopify development or just product APIs
Hey @windmillcode!
This AMA is specifically for the new Graph QL products API
The productSet mutation can be run in synchronous mode. By default, this is false, which will allow setting more than 100 variants, but returns a ProductSetOperation result. When it's true, you can't set more than 100 variants. But there's also the following note:
Note: When run in the context of a bulk operation, the mutation will always run synchronously and this argument will be ignored.
This means that it's not possible to set more than 100 variants when using a bulk operation. This makes no sense since bulk operations are already asynchronous, so it should just ignore this parameter and always run async, but instead of returning a ProductSetOperation, it should wait for it to finish and return the actual results in the bulk mutation results.
Does shopify products api offer a currency map like USD -> $ and so on?
Or better yet in MoneyPriceV2 can the currency icon come along with the amount,currencyCode object from MoneyV2 as currencyIcon?
Is there a reason why the Products endpoint in the REST API that was deprecated in the 2024-04 version is not working in the 2024-01 version when using the ruby gem?
👋 Hey Dan,
No, there shouldn't be any reason that stopped working. What kind of error are you getting back?
Also if you have the shop you are testing on and the api_client_id I might be able to find some info to help us debug this more.
How can I create a new product and associate it with a media (ex - Video, 3D Model) that already exists on a different product in the same store, without having to download, restage and upload the media again? Since the media is already present in Shopify CDN, CreateMediaInput.originalSource should be able to take the Shopify Media CDN Link as input. Different products should be able to share the same media?
Hi @abhiroop
Files uploaded to shopify (for example, with fileCreate) can be associated to many products simply using the file_id being returned. Querying for the file and using its ID will work (even if it’s the product media ID)
Hi Shopify developers
I checked the new ProductSet mutation api, it's very important for us to export the product from ERP to Shopify store, but I found that the input fields under the variant level are less than the fields in the ProductVariantCreate API, it doesn't include the inventoryItemInput in the ProductSet api, that means we cannot use ProductSet API to publish all data once, we have to call 2 or more APIs to create/update product and vairants. Do you have a plan to include these fields in the ProductSet API as well?
We use the product and variants API across hundreds of integrations. However, rewriting everything into GraphQL is not a scalable solution for us, since we are a small team. Is there an open-source project that can automatically transform the REST payload into a product or variant GraphQL payload?
We could implement a layer to convert REST requests into GraphQL variables, and another layer to transform responses, this could alleviate some difficulties in manually moving hundreds of integrations to GraphQL. I understand that using GraphQL in this manner might not be the most efficient approach. I also acknowledge that maintaining a layer of backward compatibility would necessitate different API calls especially if you are trying to create a product and variant at the same time.
Would the deprecation of /products and /variant affect the webhook payload? I've been integrating many Shopify GraphQL queries and webhooks and have found inconsistencies between the payloads. In REST, GETs and the webhook payload match, allowing me to query the same payload that I receive in the webhook. Unfortunately, this is not the case for many GraphQL webhooks and their queries.
The old create product variant api uses a queuing system when new variants are created via api. This meant that new variants are not created immediately. This cause all sorts of issues when viewing the cart before the variants have been fully added. The item is there, but Important Information is missing like the price.
Question, will the new graphQL version of create product variant have this same limitation / problem or will it allow for immediate creation of new variants, without going into a queue?
👋 Hi @strategicsystem ,
Both the new and old API work in pretty similar ways. At the point where your app receives a 200 back from Shopify all the data that was passed in your variant create call will be persisted to Shopify’s databases. For that to get to the storefront it has to publish which can have a small amount of lag, but when the data that shows up on storefront it should not have any partial information (eg missing prices).
I wonder if the issue you are seeing is maybe some kind of caching issue related to cart. Are there specific steps I can take to attempt to reproduce the issue?
Will the deprecation impact the /product.json available on the website for clients? For instance, I can currently access this endpoint https://<UUID>.myshopify.com/products.json to gather information about the products from the browser.
for the customer and product query when trying to add the query parameter filter to subscriptionContracts I get an error saying that query is not a field even though it clearly states it in the docs for 2024-04
👋 Hi @windmillcode ,
I just double-checked the docs, and it doesn't look like subscription_contracts is something which is supported by the products query in 2024-04.
https://shopify.dev/docs/api/admin-graphql/2024-04/queries/products#argument-query
We need variantsCount also similar to productsCount
I can't find it in docs
Currently we use variants/count.json
Ideally we'd like you to provide equivalent GraphQL solutions for all the REST deprecations.
You can query variantsCount on a product like this:
query variantsCount {
product(id: "gid://shopify/Product/1"){
id
variants(first: 10) {
nodes {
id
title
}
}
variantsCount(query: "title:Nylon*") {
count
precision
}
}
}
ALIAS | 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
Looking back in time about 20 years, the Yahoo Store XML product exports were simple, static XML files. Now we have GraphQL that is supposed to be way more 'advanced', but totally fails to answer extremely simple questions like:
a) Is the product data changed since I last retrieved it?
b) What is the total size of the product data?
c) What is the total count of products/variants?
d) Can I fetch all the data in one API call, fast, with gzip compression?
Shopify could easily provide a variants.jsonl static file that implements all of the above, updated once per hour, retrieved via a simple HTTP GET request to a static resource.
A simple, super-fast and efficient HTTP HEAD request could answer all the questions above by simply returning:
Last-Modified header
Size header
Count Products custom header
This is useful when we don't need 'up-to-the-second' the product information and we cache the product information on our end.
This would be a one-time and small investment on your end, but save bucket-loads of development efforts on our end.
Alternatively, you can add GraphQL endpoints that answer the questions above.
Hi @Shailesh_-_Aten ,
Thanks for raising this. Agree we don't provide this currently in a simple way, will take this into account for future API versions.
Could you clarify what you mean by “Size header”?
We currently support a productFeed for channel apps. Additionally any app can subscribe to the products webhooks to get notifications for changes to any product. Could you tell us more about your usecase and why this doesnt solve for it?
Which API we should use to set up different price for the different marketplace?
Per-market pricing is not currently supported via our APIs. Today, prices can be managed per region, B2B and company location.
To learn more visit the Shopify Help Center or the Community Blog.
A GraphQL query exists for /products/count.json - Shopify API Documentation.
However, I'm unable to find equivalent GraphQL queries for these APIs:
Is there a way to accomplish these counts with the existing GraphQL queries, or are there plans to support these count queries in the future?
👋 Hi Darryl,
You can look at the `totalVariants` field and the `mediaCount` field that are part of the product query - https://shopify.dev/docs/api/admin-graphql/2024-01/queries/product . That should give you the same counts you were using in REST.
@tedtate variants/count.json in REST api gives the total variants of a store. That's what we app developers really need.
Your answer is for the variants "under" each product. not the same thing.
Can you please address this
variantCount (released in Apr-2024) on the product object is the sibling to mediaCount.
To learn more visit the Shopify Help Center or the Community Blog.
The productSet mutation can be run in synchronous mode. By default, this is false, which will allow setting more than 100 variants, but returns a ProductSetOperation result. When it's true, you can't set more than 100 variants. But there's also the following note:
Note: When run in the context of a bulk operation, the mutation will always run synchronously and this argument will be ignored.
This means that it's not possible to set more than 100 variants when using a bulk operation. This makes no sense since bulk operations are already asynchronous, so it should just ignore this parameter and always run async, but instead of returning a ProductSetOperation, it should wait for it to finish and return the actual results in the bulk mutation results.
Hi @DavidT ,
When the mutation is run in the context of bulk operation we should be accepting more 100 variants. Please let us know if this is not the case ATM and we will fix it
I have not actually tested it, I was just going by the note in the docs here: https://shopify.dev/docs/api/admin-graphql/2024-07/mutations/productSet#argument-synchronous
I think this behavior should be clarified. Because it says, "To use this mutation with more than 100 variants in the input, the mutation must be run asynchronously." But then it says "Note: When run in the context of a bulk operation, the mutation will always run synchronously and this argument will be ignored." So I guess it should clarify that with bulk operations it will run synchronously, but will still accept more than 100 variants (exception to the first note).
We changed the latest API version 2024-07 to make productSet run synchronously by default. There is no longer the limitation of 100 variants when run synchronously.
Cheers
Hello @AsafGitai ,
Context: currently, `productSet` response supports returning up to 250 variants regardless of the value passed in `asynchronous` property.
Follow up question, can I fetch more than 250 variants in the response of a `productSet` when it runs in the context of a bulk operation?
Can we simply query fulfillmentOrder, itemInventory, and other nodes without having to wrap them in a parent query like Product/Order/etc? This would greatly simplify querying the GraphQL APIs.
Thanks for the general interest in Shopify’s GraphQL APIs. Today’s AMA is focused on Product APIs. inventoryItems does provide access to directly querying inventoryItems.
To learn more visit the Shopify Help Center or the Community Blog.
I've already raised this issue, but there is currently no good solution for bulk adding/removing media to products and variants since those fields were removed from `productUpdate`. Also `mediaId` on `productVariantUpdate` only works when creating the variant.
We need this ability back on those mutations (similar to how images worked) so we can use them in a bulk operation. Otherwise it looks like we can use the `productSet` mutation, but the issue is we have to include all the variants and options, which isn't necessary if we just want to edit the media. This makes the input file much larger than necessary, and will exceed the 20mb limit for a bulk operation a lot sooner.
I second this issue. When providing supplier product and image sync services to merchants, media files update is a thorny issue. Anything you can do to make the API calls easier to implement would be welcome.
HI @DavidT
We mentioned this also in the migration docs https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model/api-updates , for updating variant medias in bulk you can also use https://shopify.dev/docs/api/admin-graphql/2023-10/mutations/productvariantsbulkupdate
Hi @AsafGitai, I don't think these solutions will work at all.
The migration docs at https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model/product-model-components#async... doesn't give any solution for product media, because it says to just use the mediaId field on productUpdate, but this field doesn't exist anymore. The only option is to pass a list of media to add in the top level media field, and I don't think that's even possible with bulk mutations. But this won't work since I need to be able to remove and reorder media as well, similar to how you can pass a list of media IDs to productSet.
productVariantsBulkUpdate is not listed as supported by bulk operations. And even if it was, it would be redundant to run a "bulk update" mutation in a bulk operation. Since a bulk operation is already async, it should be possible to edit the mediaID (and mediaSrc when adding media) in the productVariantUpdate mutation during a bulk operation.
I understand the reasons for removing all these fields on productUpdate and productVariantUpdate since they take more time and need to run asynchronously. However, it should still be possible to use these fields when running a bulk operation, since that is already running async as stated above. This also applies to the options and variants fields on productUpdate that were removed. The only solution now for editing options in a bulk mutation is productSet.
In the REST endpoint for images, the object looks like this:
{
"created_at": "2012-03-13T16:09:58-04:00",
"id": 850703190,
"position": 1,
"product_id": 632910392,
"variant_ids": [ 808950810 ],
"src": "http://static.shopify.com/products/ipod-nano.png",
"width": 640,
"height": 480,
"updated_at": "2012-03-13T16:09:58-04:00"
}
Here is the REST documentation. https://shopify.dev/docs/api/admin-rest/2024-04/resources/product-image#resource-object
However, looking at the GraphQL object, https://shopify.dev/docs/api/admin-graphql/2024-04/objects/Image, it's missing fields such as created_at, updated_at, and position.
Do you know how I can query for those missing fields?
This is an accepted solution.
The AMA is now closed. Questions asked past this time will be moved to the appropriate community board.
Thank you to everyone who joined us for this AMA, and for all your excellent questions. Even though our time is up our team will continue to post answers to the questions that have already been asked. We will do our best to answer them as soon as possible.
Make sure you subscribe to our Community AMAs board to be notified about any future community events.
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024