Cart metafields not available in Discount Function API despite documentation

Hi, I’m trying to access cart metafields in a discount function using the query documented at https://shopify.dev/docs/api/functions/2025-10/discount#Input.fields.cart.metafield

My GraphQL query:

query Input {
  cart {
    metafield(namespace: "custom", key: "offer") {
      value
      type
    }
    lines {
      id
      cost {
        subtotalAmount {
          amount
        }
      }
    }
  }
  discount {
    discountClasses
  }
}

Error from Shopify CLI:

error: Error: Field `metafield` does not exist on type `Cart`

api_version = “2025-10”

What target are you using please :folded_hands:

This is the default discount function template + adding metafield to the input query + trying to assign its value to a variable on the rust code.

[[extensions.targeting]]
target = “cart.lines.discounts.generate.run”
input_query = “src/cart_lines_discounts_generate_run.graphql”
export = “cart_lines_discounts_generate_run”

Ah got it now! Thanks for the info just needed to test it myself.

If your api_version = “2025-10” in your extension TOML, then you’ll need to regenerate the schema.

You can run npm run shopify app function schema in the extension folder and it’ll update the schema.
It will use the api version in your extension toml, the default is 2025-04 so guessing thats the version you have when the new extension was generated/created.

Then you’ll be able to run the typegen successfully!