i am looking for query schema how to create variants in bulk via graphql api i tried but its giving errors on syntax when i include the required fields to the schema. The data i need to pass is
variants [
{
option1: ‘string’,
price: number,
inventory_management: null,
fulfillment_service: ‘manual’
}
]
Hey @techticmukesh ,
Taking a closer look at the docs for the productVariantBulkCreate mutation and the ProductVariantsBulkInput input object, these are probably the place to start working from. While I can’t provide specifics for how this can be implemented in your code, the first doc does have examples you can build from if you are using one of our Support API libraries (Ruby, PHP, Node.js), in addition to raw GraphQL examples.
I was able to do some testing and had great success working from the examples provided as a base. If you are using API version 2022-07 or later, you can use the mutation to set both the InventoryItemInput.tracked to set a value of true, and **ProductVariantsBulkInput.**inventoryQuantities InventoryLevelInput to set the locationId of the fulfillment service you wish to handle inventory and fulfillment.
The doc also goes over this in greater detail, outlining the deprecated FulfillmentServiceId field that was previously used for the input. It expands on the change, with links to a number helpful resources and guides that cover an overview for current workflows of apps that handle inventory management as well as for fulfillment services - see image below.
My final suggestion here would be to consider using an API client like Insomnia or Postman for further exploration with structuring and testing the GraphQL APIs. I hope this info helps point you towards the solution you’re building!
Cheers - @awwdam
Shopify Developer Support