Creating fixed bundles with the GraphQL API

Topic summary

A developer is encountering an error when attempting to create a variant-level product bundle using Shopify’s GraphQL API. The issue centers on a discrepancy between the API documentation and actual implementation.

The Problem:

  • The mutation documentation shows an example using a variants field within ProductInput
  • However, the actual ProductInput object definition does not include a variants field
  • When following the documented example, the API returns an error: “Field is not defined on ProductInput”

Technical Details:

  • The mutation productCreate expects input of type ProductInput
  • The provided example includes variants array with price data
  • The error message explicitly states that variants is not a valid field for the ProductInput type

This appears to be a documentation inconsistency where the example code doesn’t align with the actual GraphQL schema definition. The discussion remains open with no resolution provided yet.

Summarized with AI on November 7. AI used: claude-sonnet-4-5-20250929.

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