Discuss all the new features introduced with the new product model in GraphQL.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Using the GraphQL API, is there a way to create a product with product variants and images for each variant using a single API call?
Solved! Go to the solution
This is an accepted solution.
https://shopify.dev/docs/api/admin-graphql/2024-07/mutations/productCreate
this is how to create a variant
https://shopify.dev/docs/api/admin-graphql/2024-07/mutations/productVariantCreate
here is your answer. You need to use the productCreate mutation AND the productVariantCreate mutation. You can‘t set it from one call. You could just wrap them both in a single function though
This is an accepted solution.
https://shopify.dev/docs/api/admin-graphql/2024-07/mutations/productCreate
this is how to create a variant
https://shopify.dev/docs/api/admin-graphql/2024-07/mutations/productVariantCreate
here is your answer. You need to use the productCreate mutation AND the productVariantCreate mutation. You can‘t set it from one call. You could just wrap them both in a single function though
@Geist my question was more about creating the product using the GraphQL. Since product creation using REST is being deprecated, I am moving all my code to use the GraphQL and was wondering how I go about doing this in a single call.
in graphql every fetch call is a POST request so if you want to update the server you must use a mutation. I would note that each call to the graphql admin api must come from a server. You cant hit it from the front end. You either need to get a backend app up and running or use a serverless function
I understand, how to make the GraphQL calls using a server. Just figuring out if there is a way to create a product
- with 2 Options and 6 Option values
- with 20 images
- with 100+ variants
All of the above using a single graphQL call using the mutation query.
No you can‘t do it with a single call. Creating a product requires one mutation creating a variant requires another mutation.
I was looking at the same, just trying to find examples on how to do that.