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
{
 customAttributeMetadata(
   attributes: {
     attribute_code: "color"
     entity_type: "4"
   }
 ) {
   items {
     attribute_code
     entity_type
     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
{
  "data": {
    "customAttributeMetadata": {
      "items": [
        {
          "attribute_code": "color",
          "entity_type": "4",
          "attribute_type": "Int",
          "attribute_options": [
            {
              "value": "49",
              "label": "Black"
            },
            {
              "value": "214",
              "label": "blue"
            },
            {
              "value": "215",
              "label": "green"
            },
            {
              "value": "213",
              "label": "red"
            },
            {
              "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 customAttributeMetadata query requires the following attributes as input.

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

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