customAttributeMetadata query

The customAttributeMetadata query returns the attribute type, given an attribute code and entity type. All entity attributes can be added to an equivalent GraphQL type, including custom, extension, and EAV (which have precedence set in that order for collisions). The GraphQL query consumer does not have the ability to know a field’s attribute type.

Syntax

customAttributeMetadata(attributes: [AttributeInput!]!): CustomAttributeMetadata

Example usage

The following query returns the attribute type for various custom and EAV attributes.

Request:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
  customAttributeMetadata(
    attributes: [
      {
        attribute_code: "size"
        entity_type: "4"
      }
      {
        attribute_code: "color"
        entity_type: "4"
      }
    ]
  ) {
    items {
      attribute_code
      attribute_type
      attribute_options {
       value
       label
     }
    }
  }
}

Response:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
{
  "data": {
    "customAttributeMetadata": {
      "items": [
        {
          "attribute_code": "size",
          "attribute_type": "Int",
          "attribute_options": [
            {
              "value": "91",
              "label": "55 cm"
            },
            {
              "value": "169",
              "label": "XS"
            },
            {
              "value": "92",
              "label": "65 cm"
            },
            {
              "value": "170",
              "label": "S"
            },
            {
              "value": "93",
              "label": "75 cm"
            },
            {
              "value": "171",
              "label": "M"
            },
            {
              "value": "94",
              "label": "6 foot"
            },
            {
              "value": "172",
              "label": "L"
            },
            {
              "value": "95",
              "label": "8 foot"
            },
            {
              "value": "173",
              "label": "XL"
            },
            {
              "value": "96",
              "label": "10 foot"
            },
            {
              "value": "174",
              "label": "28"
            },
            {
              "value": "175",
              "label": "29"
            },
            {
              "value": "176",
              "label": "30"
            },
            {
              "value": "177",
              "label": "31"
            },
            {
              "value": "178",
              "label": "32"
            },
            {
              "value": "179",
              "label": "33"
            },
            {
              "value": "180",
              "label": "34"
            },
            {
              "value": "181",
              "label": "36"
            },
            {
              "value": "182",
              "label": "38"
            }
          ]
        },
        {
          "attribute_code": "color",
          "attribute_type": "String",
          "attribute_options": [
            {
              "value": "49",
              "label": "Black"
            },
            {
              "value": "50",
              "label": "Blue"
            },
            {
              "value": "51",
              "label": "Brown"
            },
            {
              "value": "52",
              "label": "Gray"
            },
            {
              "value": "53",
              "label": "Green"
            },
            {
              "value": "54",
              "label": "Lavender"
            },
            {
              "value": "55",
              "label": "Multi"
            },
            {
              "value": "56",
              "label": "Orange"
            },
            {
              "value": "57",
              "label": "Purple"
            },
            {
              "value": "58",
              "label": "Red"
            },
            {
              "value": "59",
              "label": "White"
            },
            {
              "value": "60",
              "label": "Yellow"
            }
          ]
        }
      ]
    }
  }
}

Input attributes

The AttributeInput input object requires the following attributes.

Attribute Data Type Description
attribute_code String The unique identifier for an attribute code. This value should be in lowercase letters without spaces
entity_type String The type of entity that defines the attribute

Output attributes

The CustomAttributeMetadata object is an array of items. The items object can contain the following attributes.

Attribute Data Type Description
attribute_code String The unique identifier for an attribute code. This value should be in lowercase letters without spaces
attribute_options [AttributeOption] An array of attribute options
attribute_type String The data type of the attribute
entity_type String The type of entity that defines the attribute
input_type String The frontend input type of the attribute

AttributeOption object

The AttributeOption object contains the name and value of the option.

Attribute Data Type Description
label String The name of an attribute option
value String The value assigned to an attribute option