CustomField
Represents a product’s custom field, including its value, type, and handle.
Type Definition
type CustomField {
title: String
handle: String
value: String
type: String
}
Fields
Field | Type | Nullable | Description | Relationships |
---|---|---|---|---|
title | String | Yes | The display title of the custom field. | None |
handle | String | Yes | The unique handle for the custom field. | None |
value | String | Yes | The value assigned to the custom field. | None |
type | String | Yes | The type of the custom field (e.g., text, number). | None |
Relationships
The CustomField
type does not have direct relationships to other object types. It is typically used as a nested object within other types, such as products, to represent additional structured metadata.
Usage Examples
Basic Query
{
customField {
title
handle
value
type
}
}
Field Selection
{
customField {
title
value
}
}
Nested Queries
{
product(id: 12345) {
id
name
customField {
handle
value
type
}
}
}
Filtering and Sorting
The CustomField
type itself does not support direct filtering or sorting. Filtering and sorting should be applied on the parent object that contains CustomField
. For example, filtering products by a custom field value would be done at the product query level.
{
products(filter: { customFieldHandle: "color", customFieldValue: "red" }, sort: { field: "name", direction: ASC }) {
edges {
node {
id
name
customField {
handle
value
}
}
}
}
}
(Note: Adjust filtering and sorting syntax based on the parent type’s capabilities.)
Implements
The CustomField
type does not implement any interfaces.
Connections
CustomField
does not have connection fields or pagination as it is a simple object type.
Related Types
- Product (commonly contains
CustomField
objects to represent additional metadata)
Best Practices
- Use the
handle
field as a stable identifier for referencing custom fields programmatically. - Use the
type
field to understand how to interpret thevalue
(e.g., parse as number if type is “number”). - When querying nested
CustomField
objects, select only the fields you need to optimize query performance. - Since all fields are optional, always check for null values in your client code to avoid runtime errors.
Notes
- All fields in
CustomField
are optional and may returnnull
if not set. - This type is designed for flexible metadata storage and does not enforce strict validation on
value
based ontype
. - The API currently requires no authentication, but this may change in future versions. Plan your integration accordingly.
- Avoid over-fetching by selecting only necessary fields to improve response times and reduce payload size.