App reviews, troubleshooting, and recommendations
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
I am trying to create a variant-level product bundle with the GraphQL API, but I am getting an error which implies that the documentation does not match the requirements of the field.
As you can see here, the mutation expects input to be of type ProductInput:
mutation CreateProductBundle($input: ProductInput!) { productCreate(input: $input) { product { title variants(first: 10) { edges{ node{ id price } } } } userErrors{ field message } } }
And the example shared shows an example of input as:
{ "input": { "title": "The Hair And Skin Bundle", "variants": [ { "price": 10 } ] } }
However, when I check the ProductInput object, it doesn't have a field called 'variants' https://shopify.dev/docs/api/admin-graphql/2024-07/input-objects/ProductInput
When I try to run the mutation with my $input taking the same shape as the given example, I get this error:
{"errors":[{"message":"Variable $input of type ProductInput! was provided invalid value for variants (Field is not defined on ProductInput)","locations":[{"line":2,"column":38}],"extensions":{"value":{"title":"Test","variants":"{\"price\":10}"},"problems":[{"path":["variants"],"explanation":"Field is not defined on ProductInput"}]}}]}
which is not unexpected because variants does not exist in the ProductInput object.
Ref: https://shopify.dev/docs/apps/build/product-merchandising/bundles/add-variant-fixed-bundle