Get Attribute
About
The getAttribute query retrieves a single attribute by ID with support for nested options, translations, and detailed configuration metadata. This query is essential for:
- Building product filter interfaces with attribute options
- Displaying attribute details in admin/management interfaces
- Creating product configuration forms
- Fetching attribute properties and validation rules
- Building faceted navigation systems with swatch support
The query supports nested pagination for options and translations, making it flexible for various UI requirements.
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
id | String! | ✅ Yes | Attribute ID in format /api/shop/attributes/{id} or numeric ID |
Supported ID Formats:
graphql
# Format 1: Full URI
query { attribute(id: "/api/shop/attributes/23") { id } }
# Format 2: Numeric ID
query { attribute(id: "23") { id } }Possible Returns
| Field | Type | Description |
|---|---|---|
id | String! | Unique attribute identifier in IRI format /api/shop/attributes/{id} |
code | String! | Unique code identifier (e.g., "color", "size", "brand") |
name | String! | Display name of the attribute |
type | String! | Attribute type (text, select, date, checkbox, textarea, etc.) |
sortOrder | Int! | Display order for sorting |
isFilterable | Boolean! | Can be used for product filtering |
isSearchable | Boolean! | Can be used in product search |
isConfigurable | Boolean! | Can be configured for products |
isVisibleOnFront | Boolean! | Visible to frontend customers |
isRequired | Boolean! | Required for product assignment |
defaultValue | String | Default value (nullable) |
createdAt | DateTime! | Creation timestamp (ISO 8601) |
updatedAt | DateTime! | Last update timestamp (ISO 8601) |
options | Connection | Attribute options with pagination support |
Attribute Fields
| Field | Type | Description |
|---|---|---|
id | String! | Unique identifier in format /api/shop/attributes/{id} |
code | String! | Unique code identifier for attribute |
name | String! | Display name of the attribute |
type | String! | Attribute type (text, select, date, etc.) |
sortOrder | Int! | Display sort order |
isFilterable | Boolean! | Usable for product filtering |
isSearchable | Boolean! | Usable for search |
isConfigurable | Boolean! | Can be configured for products |
isVisibleOnFront | Boolean! | Visible on storefront |
isRequired | Boolean! | Required for products |
defaultValue | String | Default value if any |
createdAt | String! | Creation date |
updatedAt | String! | Last update date |
options | Connection | Nested attribute options with pagination |
Common Use Cases
Get Attribute for Filter UI
graphql
query GetAttributeFilter($id: String!) {
attribute(id: $id) {
id
code
name
isFilterable
options(first: 100) {
edges {
node {
id
adminName
translation {
label
}
}
}
}
}
}Get Attribute with Option Swatches
graphql
query GetColorAttribute($id: String!) {
attribute(id: $id) {
id
code
name
type
options(first: 50) {
edges {
node {
id
adminName
swatchValue
translation {
label
}
}
}
}
}
}Build Product Configuration Form
graphql
query GetAttributeForForm($id: String!) {
attribute(id: $id) {
id
code
name
type
isRequired
defaultValue
options(first: 100) {
edges {
node {
id
adminName
sortOrder
translation {
label
}
}
}
}
}
}Get Multi-language Attribute
graphql
query GetMultiLanguageAttribute($id: String!) {
attribute(id: $id) {
id
code
name
options(first: 20) {
edges {
node {
id
adminName
translations(first: 10) {
edges {
node {
locale
label
}
}
}
}
}
}
}
}Error Handling
Missing ID Parameter
json
{
"errors": [
{
"message": "Field \"attribute\" argument \"id\" of type \"String!\" is required but not provided."
}
]
}Attribute Not Found
json
{
"data": {
"attribute": null
}
}Invalid ID Format
json
{
"data": {
"attribute": null
}
}Best Practices
- Use Variables - Always use GraphQL variables for dynamic IDs
- Request Specific Fields - Only fetch fields your UI needs
- Handle Pagination - Use
hasNextPageandendCursorfor nested options - Cache Results - Attributes rarely change, implement caching
- Limit Option Requests - Start with reasonable limits (20-50) then load more on demand
Related Resources
- Pagination Guide - Cursor pagination documentation
- Attribute Collection - Query multiple attributes
- Attribute Options API - Detailed option queries
- Attributes API - Full attributes documentation
- Shop API Overview - Overview of Shop API resources

