Skip to content

Update function templates 2025-07 #637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
258 changes: 254 additions & 4 deletions checkout/javascript/cart-checkout-validation/default/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Scale the Functions resource limits based on the field's length.
"""
directive @scaleLimits(rate: Float!) on FIELD_DEFINITION

"""
Requires that exactly one field must be supplied and that field must not be `null`.
"""
directive @oneOf on INPUT_OBJECT

"""
A custom property. Attributes are used to store additional information about a Shopify resource, such as
products, customers, or orders. Attributes are stored as key-value pairs.
Expand Down Expand Up @@ -104,7 +109,7 @@ enum BuyerJourneyStep {
The cart where the Function is running. A cart contains the merchandise that a customer intends to purchase
and information about the customer, such as the customer's email address and phone number.
"""
type Cart {
type Cart implements HasMetafields {
"""
The custom attributes associated with a cart to store additional information. Cart attributes
allow you to collect specific information from customers on the **Cart** page, such as order notes,
Expand Down Expand Up @@ -168,6 +173,34 @@ type Cart {
"""
keys: [LocalizedFieldKey!]! = []
): [LocalizedField!]!

"""
A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information
about a Shopify resource, such as products, orders, and
[many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType).
Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries)
enables you to customize the checkout experience.
"""
metafield(
"""
The unique identifier for the metafield within its namespace. A metafield is composed of a
namespace and a key, in the format `namespace.key`.
"""
key: String!

"""
A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts
between different apps or different parts of the same app. If omitted, then the
[app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership)
is used.
"""
namespace: String
): Metafield

"""
The physical location where a retail order is created or completed.
"""
retailLocation: Location
}

"""
Expand Down Expand Up @@ -221,6 +254,11 @@ type CartDeliveryGroup {
"""
deliveryOptions: [CartDeliveryOption!]!

"""
The type of merchandise in the delivery group.
"""
groupType: CartDeliveryGroupType!

"""
A [globally-unique ID](https://shopify.dev/docs/api/usage/gids)
for the delivery group.
Expand All @@ -233,6 +271,22 @@ type CartDeliveryGroup {
selectedDeliveryOption: CartDeliveryOption
}

"""
Defines what type of merchandise is in the delivery group.
"""
enum CartDeliveryGroupType {
"""
The delivery group only contains merchandise that is either a one time purchase or a first delivery of
subscription merchandise.
"""
ONE_TIME_PURCHASE

"""
The delivery group only contains subscription merchandise.
"""
SUBSCRIPTION
}

"""
Information about a delivery option that's available for an item in a cart. Delivery options are the different
ways that customers can choose to have their orders shipped. Examples include express shipping or standard
Expand Down Expand Up @@ -363,6 +417,28 @@ type CartLineCost {
totalAmount: MoneyV2!
}

"""
The fetch target result. Your Function must return this data structure when generating the request.
"""
input CartValidationsGenerateFetchResult {
"""
The attributes associated with an HTTP request.
"""
request: HttpRequest
}

"""
The output of the Function run target. The object contains the validation errors
that display to customers and prevent them from proceeding through checkout.
"""
input CartValidationsGenerateRunResult {
"""
An ordered list of operations to be executed for the validations associated with the
cart and checkout processes.
"""
operations: [Operation!]!
}

"""
Whether the product is in the specified collection.

Expand Down Expand Up @@ -3099,7 +3175,7 @@ type Input {
your fetch target, and that is passed as input to the run target. For more
information, refer to [network access for Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/network-access).
"""
fetchResult: HttpResponse @restrictTarget(only: ["purchase.validation.run"])
fetchResult: HttpResponse @restrictTarget(only: ["purchase.validation.run", "cart.validations.generate.run"])

"""
The regional and language settings that determine how the Function
Expand Down Expand Up @@ -3973,7 +4049,7 @@ type Localization {
"""
The market of the active localized experience.
"""
market: Market!
market: Market! @deprecated(reason: "This `market` field will be removed in a future version of the API.")
}

"""
Expand Down Expand Up @@ -4189,6 +4265,119 @@ enum LocalizedFieldKey {
TAX_EMAIL_IT
}

"""
Represents the location where the inventory resides.
"""
type Location implements HasMetafields {
"""
The address of this location.
"""
address: LocationAddress!

"""
The location handle.
"""
handle: Handle!

"""
The location id.
"""
id: ID!

"""
A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information
about a Shopify resource, such as products, orders, and
[many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType).
Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries)
enables you to customize the checkout experience.
"""
metafield(
"""
The unique identifier for the metafield within its namespace. A metafield is composed of a
namespace and a key, in the format `namespace.key`.
"""
key: String!

"""
A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts
between different apps or different parts of the same app. If omitted, then the
[app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership)
is used.
"""
namespace: String
): Metafield

"""
The name of the location.
"""
name: String!
}

"""
Represents the address of a location.
"""
type LocationAddress {
"""
The first line of the address for the location.
"""
address1: String

"""
The second line of the address for the location.
"""
address2: String

"""
The city of the location.
"""
city: String

"""
The country of the location.
"""
country: String

"""
The country code of the location.
"""
countryCode: String

"""
A formatted version of the address for the location.
"""
formatted: [String!]!

"""
The approximate latitude coordinates of the location.
"""
latitude: Float

"""
The approximate longitude coordinates of the location.
"""
longitude: Float

"""
The phone number of the location.
"""
phone: String

"""
The province of the location.
"""
province: String

"""
The code for the province, state, or district of the address of the location.
"""
provinceCode: String

"""
The ZIP code of the location.
"""
zip: String
}

"""
Represents a mailing address.
"""
Expand Down Expand Up @@ -4241,7 +4430,7 @@ type MailingAddress {
"""
The market of the address.
"""
market: Market
market: Market @deprecated(reason: "This `market` field will be removed in a future version of the API.")

"""
The full name of the customer, based on firstName and lastName.
Expand Down Expand Up @@ -4400,6 +4589,26 @@ type MoneyV2 {
The root mutation for the API.
"""
type MutationRoot {
"""
Handles the Function result for the cart.validations.generate.fetch target.
"""
cartValidationsGenerateFetch(
"""
The result of the Function.
"""
result: CartValidationsGenerateFetchResult!
): Void!

"""
Handles the Function result for the cart.validations.generate.run target.
"""
cartValidationsGenerateRun(
"""
The result of the Function.
"""
result: CartValidationsGenerateRunResult!
): Void!

"""
Handles the Function result for the purchase.validation.fetch target.
"""
Expand Down Expand Up @@ -4431,6 +4640,17 @@ type MutationRoot {
): Void!
}

"""
An operation to apply.
"""
input Operation @oneOf {
"""
An operation that adds validations to the cart and checkout. For example, you might add a validation
that, at checkout, confirms a customer's age meets the legal requirement to purchase a product in their cart.
"""
validationAdd: ValidationAddOperation
}

"""
The goods and services that merchants offer to customers. Products can include details such as
title, vendor, and custom data stored in [metafields](https://shopify.dev/docs/apps/build/custom-data).
Expand Down Expand Up @@ -4820,6 +5040,36 @@ type Validation implements HasMetafields {
): Metafield
}

"""
An operation that adds validations to the cart and checkout. For example, you might add a validation
that, at checkout, confirms a customer's age meets the legal requirement to purchase a product in their cart.
"""
input ValidationAddOperation {
"""
The validation errors that block a customer from proceeding through checkout.
The errors are grouped by
[target](https://shopify.dev/docs/api/functions/reference/cart-checkout-validation/graphql#supported-checkout-field-targets).
"""
errors: [ValidationError!]!
}

"""
A Function error for a path.
"""
input ValidationError {
"""
A description of the validation error. For example, "The product is out of stock" or
"The product isn't available for purchase in your region".
"""
message: String!

"""
The [identifier](https://shopify.dev/docs/api/functions/reference/cart-checkout-validation/graphql#supported-checkout-field-targets)
in `shopify.extension.toml` that specifies where you're injecting code in the checkout process.
"""
target: String!
}

"""
A void type that can be used to return a null value from a mutation.
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
api_version = "2025-01"
api_version = "2025-07"

[[extensions]]
name = "t:name"
Expand All @@ -8,11 +8,10 @@ type = "function"
description = "t:description"

[[extensions.targeting]]
target = "purchase.validation.run"
input_query = "src/run.graphql"
export = "run"
target = "cart.validations.generate.run"
input_query = "src/cart_validations_generate_run.graphql"
export = "cart-validations-generate-run"

[extensions.build]
command = ""
path = "dist/function.wasm"

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
query RunInput {
query CartValidationsGenerateRunInput {
cart {
lines {
quantity
Expand Down
Loading
Loading