Development discussions around Shopify APIs
I am using this code to create a variant. It creates the variant without any issues.
mutation($input: ProductVariantInput!) { productVariantCreate(input: $input) { product { id } productVariant { id } userErrors { field message } } } variables = {input: { productId: "gid://shopify/ProductVariant/31750928957536", barcode: "2345678911", options: ["Red", "Large"], price: price, inventoryManagement: "SHOPIFY" }}
I am using this code to get variant by barcode.
query($query: String) { productVariants(first: 1, query: $query) { edges { node { id product { id tags } } } } } variables = {query: "barcode:2345678911"}
But I can't get the variant asap using this code after running mutation to create variant.
The interesting note is that after a few minutes(1~2 minutes) I can get variant by barcode using the above code.
This code is not working only if trying to get variant asap after a new variant with the barcode is created.
Is there any reason?
Solved! Go to the solution
This is an accepted solution.
Hi @Yu727
When you run the initial mutation to create the variant, it triggers a service to index the product in your list. With that said, the variant being indexed isn't instant which is why you were seeing a delay for the variant to show up in your query. This delay is often around 30 seconds on a normal basis, depending on the number of products and other factors, this could be slightly longer like you are seeing. Are you able to reproduce a 2+ minute delay on every attempt?
This is an accepted solution.
Hi @Yu727
When you run the initial mutation to create the variant, it triggers a service to index the product in your list. With that said, the variant being indexed isn't instant which is why you were seeing a delay for the variant to show up in your query. This delay is often around 30 seconds on a normal basis, depending on the number of products and other factors, this could be slightly longer like you are seeing. Are you able to reproduce a 2+ minute delay on every attempt?
Does the same apply to draftOrderCreate and draftOrderRetrieve? I'm seeing a delay when making the GraphQL call to create the Order and then trying to retrieve it.
Thanks very much.
I am also having an issue with waiting too long for variant creations. Here is another thread I subscribed to. I just wonder if the indexing makes the variant with $0 on the cart page. Now it's just waiting too long to add the new variant to the cart.
I tried to contact Partner Support but the staff just asked me to open another thread.
I have the same problem. We developed a product option app with dynamic pricing and also have the $0 problem on the cart page. See my video here: https://community.shopify.com/c/shopify-apis-and-sdks/add-variant-and-add-this-variant-into-the-cart...
I think this is a challenge for all apps with dynamic product options and dynamic pricing. We have many options and create a new variant with our app t
Would be great if Shopify can fix this bug/delay because with this bug it is very frustrating to build new cool apps that change the product price and based on variants.
Photo by Marco Verch Sales channels on Shopify are various platforms where you can sell...
By Ollie May 25, 2023Summary of EventsBeginning in January of 2023, some merchants reported seeing a large amo...
By Trevor May 15, 2023With 2-Factor Authentication being required to use Shopify Payments, we’re here to help yo...
By Imogen Apr 26, 2023