Skip to content
Open
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
type Query {
customAttributeMetadataV2(attributes: [AttributeMetadataInput!]!): CustomAttributeMetadata
customAttributesLists(listType: CustomAttributesListsEnum): CustomAttributeMetadata
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

customAttributesLists - do we need a better name for this

}

type AttributeMetadataInput {
attribute_uid: ID
}

type CustomAttributeMetadata { # this replaces existing Attribute type
items: [AttributeMetadataInterface]
}

interface AttributeMetadataInterface { # base metadata common to all attributes
uid: ID # base64Encode(entityID/codeID)
label: String
data_type: ObjectDataTypeEnum # string, int, float, boolean etc
sort_order: Int
entity_type: EntityTypeEnum
ui_input: UiInputTypeInterface!
}

type CustomerAttributeMetadata implements AttributeMetadataInterface {
forms_to_use_in: [CustomAttributesListsEnum]
}

type CustomerAddressAttributeMetadata implements AttributeMetadataInterface {
}

type ProductAttributeMetadata implements AttributeMetadataInterface {
lists_to_use_in: [CustomAttributesListsEnum]
}

# interfaces for different types used in inputs --------------

interface UiInputTypeInterface {
ui_input_type: EntityTypeEnum
is_value_required: Boolean!
}

interface ValidationTextInputTypeInterface {
filter: InputValidationFilterEnum
}

interface FilterableTextInputTypeInterface {
input_validation: FilterableText
}

interface AttributeOptionsInterface {
attribute_options: [AttributeOptionInterface]
}

interface AttributeOptionInterface {
uid: ID!
is_default: Boolean
label: String
}

interface SelectableInputTypeInterface {

}

interface TextInputTypeInterface {
default_value: String
}

type FilterableText {
input_validation_type: InputValidationTypeEnum
minimum_text_length: Int
maximum_text_length: Int
}

type TextUiInputType implements UiInputTypeInterface, TextInputTypeInterface, FilterableTextInputTypeInterface, ValidationTextInputTypeInterface {

}

type TextAreaUiInputType implements UiInputTypeInterface, TextInputTypeInterface, FilterableTextInputTypeInterface, ValidationTextInputTypeInterface {

}

type MultipleLineUiInputType implements UiInputTypeInterface, TextInputTypeInterface, FilterableTextInputTypeInterface, ValidationTextInputTypeInterface {
lines_count: Int
}

type DateUiInputType implements UiInputTypeInterface, TextInputTypeInterface, FilterableTextInputTypeInterface {
minimum_date_allowed: String
maximum_date_allowed: String
}

type FileUiInputType implements UiInputTypeInterface, TextInputTypeInterface, FilterableTextInputTypeInterface {
maximum_file_size: Int # bytes
allowed_file_extensions: [String]
}

type ImageUiInputType implements UiInputTypeInterface, TextInputTypeInterface, FilterableTextInputTypeInterface {
maximum_file_size: Int # bytes
allowed_file_extensions: [String]
maximum_image_width: Int # in pixels
maximum_image_height: Int # in pixels
}

type DropDownUiInputType implements UiInputTypeInterface, SelectableInputTypeInterface, AttributeOptionsInterface {
}

type MultipleSelectUiInputType implements UiInputTypeInterface, SelectableInputTypeInterface, AttributeOptionsInterface {
}

interface SwatchInputTypeInterface {
update_product_preview_image: Boolean
}

type VisualSwatchUiInputType implements UiInputTypeInterface, SelectableInputTypeInterface, AttributeOptionsInterface, SwatchInputTypeInterface {
use_product_image_for_swatch_if_possible: Boolean
}

type TextSwatchUiInputType implements UiInputTypeInterface, SelectableInputTypeInterface, AttributeOptionsInterface, SwatchInputTypeInterface {

}

type AttributeOption implements AttributeOptionInterface {
value: String @deprecated(reason: "use `uid` instead")
label: String
}

interface SelectableInputTypeInterface {

}

type ColorSwatchAttributeOption implements AttributeOptionInterface {
color: String # html hex code format
}

type ImageSwatchAttributeOption implements AttributeOptionInterface {
image_path: String # relative path
}

type TextSwatchAttributeOption implements AttributeOptionInterface {
description: String
}

#enums to support above queries
enum ObjectDataTypeEnum {
STRING
FLOAT
INT
BOOLEAN
}

enum EntityTypeEnum {
CUSTOMER
CUSTOMER_ADDRESS
CATALOG_CATEGORY
CATALOG_PRODUCT
ORDER
INVOICE
CREDITMEMO
SHIPMENT
RMA_ITEM
GENERIC
}

enum UiInputTypeEnum {
TEXT
TEXTAREA
MULTILINE
DATE
DATETIME
SELECT
MULTISELECT
BOOLEAN
FILE
IMAGE
SWATCH_VISUAL
SWATCH_TEXT
PRICE
MEDIA_IMAGE
WEEE
}

enum InputValidationTypeEnum {
ALPHANUMERIC
ALPHANUMERIC_WITH_SPACES
NUMERIC_ONLY
ALLPHA_ONLY
DATE
URL
EMAIL
LENGTH_ONLY
}

enum InputValidationFilterEnum {
STRIPTAGS
ESCAPEHTML
DATE
}

enum CustomerAttributeFormsEnum {
CUSTOMER_ACCOUNT_CREATE
CUSTOMER_ACCOUNT_EDIT
ADMINHTML_CHECKOUT
}

enum CustomAttributesListsEnum {
PRODUCTS_COMPARE
PRODUCTS_LISTING
ADVANCED_CATALOG_SEARCH
PRODUCT_SORT
PRODUCT_FILTER
PRODUCT_SEARCH_RESULTS
PRODUCT_AGGREGATIONS
RMA_FORM
CUSTOMER_REGISTRATION_FORM
CUSTOMER_ADDRESS_FORM
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,137 @@ Additionally, there should be a way to retrieve metadata for all storefront cust

# Proposed solution

Relaxing signature of existing `customAttributeMetadata` query by making its `attriubtes` argument optional will allow to fetch all storefront attributes metadata.
Relaxing signature of existing `customAttributeMetadata` query by making its `attributes` argument optional will allow to fetch all storefront attributes metadata.

Existing schema:
```graphql
Query.customAttributeMetadata(
Query.customAttributesMetadata(
attributes: [AttributeInput!]!
): CustomAttributeMetadata
```

Added schema:

```graphql
Query.customAttributesMetadataV2(
attributes: [AttributeMetadataInput!]
): CustomAttributeMetadata

#adding to existing type a choice of uid or code and
input AttributeMetadataInput {
attribute_uid: ID
}

type CustomAttributeMetadata { # this replaces existing Attribute type
items: [AttributeMetadataInterface]
}

interface AttributeMetadataInterface { # base metadata common to all attributes
uid: ID # base64Encode(entityID/codeID)
label: String
data_type: ObjectDataTypeEnum # string, int, float, boolean etc
sort_order: Int
entity_type: EntityTypeEnum
ui_input: UiInputTypeInterface!
}

type CustomerAttributeMetadata implements AttributeMetadataInterface {
forms_to_use_in: [CustomAttributesListsEnum]
}

type CustomerAddressAttributeMetadata implements AttributeMetadataInterface {
}

type ProductAttributeMetadata implements AttributeMetadataInterface {
lists_to_use_in: [CustomAttributesListsEnum]
}

type TextUiInputType implements UiInputTypeInterface, TextInputTypeInterface, FilterableTextInputTypeInterface, ValidationTextInputTypeInterface {

}

type TextAreaUiInputType implements UiInputTypeInterface, TextInputTypeInterface, FilterableTextInputTypeInterface, ValidationTextInputTypeInterface {

type AttributeInput {
attribute_code: String
entity_type: String
}

type CustomAttributeMetadata {
items: [Attribute]
type MultipleLineUiInputType implements UiInputTypeInterface, TextInputTypeInterface, FilterableTextInputTypeInterface, ValidationTextInputTypeInterface {
lines_count: Int
}

type Attribute {
attribute_code: String
attribute_options: [AttributeOption]
attribute_type: String
entity_type: String
input_type: String
type DateUiInputType implements UiInputTypeInterface, TextInputTypeInterface, FilterableTextInputTypeInterface {
minimum_date_allowed: String
maximum_date_allowed: String
}

type AttributeOption {
type FileUiInputType implements UiInputTypeInterface, TextInputTypeInterface, FilterableTextInputTypeInterface {
maximum_file_size: Int # bytes
allowed_file_extensions: [String]
}

type ImageUiInputType implements UiInputTypeInterface, TextInputTypeInterface, FilterableTextInputTypeInterface {
maximum_file_size: Int # bytes
allowed_file_extensions: [String]
maximum_image_width: Int # in pixels
maximum_image_height: Int # in pixels
}

type DropDownUiInputType implements UiInputTypeInterface, SelectableInputTypeInterface, AttributeOptionsInterface {
}

type MultipleSelectUiInputType implements UiInputTypeInterface, SelectableInputTypeInterface, AttributeOptionsInterface {
}

interface SwatchInputTypeInterface {
update_product_preview_image: Boolean
}

type VisualSwatchUiInputType implements UiInputTypeInterface, SelectableInputTypeInterface, AttributeOptionsInterface, SwatchInputTypeInterface {
use_product_image_for_swatch_if_possible: Boolean
}

type TextSwatchUiInputType implements UiInputTypeInterface, SelectableInputTypeInterface, AttributeOptionsInterface, SwatchInputTypeInterface {

}

type AttributeOption implements AttributeOptionInterface {
value: String @deprecated(reason: "use `uid` instead")
label: String
value: String
}

type ColorSwatchAttributeOption implements AttributeOptionInterface {
color: String # html hex code format
}

type ImageSwatchAttributeOption implements AttributeOptionInterface {
image_path: String # relative path
}

type TextSwatchAttributeOption implements AttributeOptionInterface {
description: String
}
```

Additional fields should be added to the metadata response (`Attribute` type), for example `is_dynamic`, `use_in_compare_products`, `display_in_product_listing`, `use_in_advanced_search`, `advanced_search_input_type`. The exact list of fields must be discussed and approved separately.

Introduction of the following query will allow fetching lists of attributes applicable to specific pages:
See full schema [attributes-metadata.graphqls](attributes-metadata.graphqls)

Introduction of the following query will allow fetching lists of attributes applicable to specific artifacts/listings:
```graphql
pageSpecificCustomAttributes(
page_type: CustomAttributesPageEnum
customAttributesLists(
listType: CustomAttributesListingsEnum
): CustomAttributeMetadata

enum CustomAttributesPageEnum {
enum CustomAttributesListingsEnum {
PRODUCTS_COMPARE
PRODUCTS_LISTING
ADVANCED_CATALOG_SEARCH
PRODUCT_SORT
PRODUCT_FILTER
PRODUCT_SEARCH_RESULTS
PRODUCT_AGGREGATIONS
RMA_FORM
CUSTOMER_REGISTRATION_FORM
CUSTOMER_ADDRESS_FORM
}
```

Expand Down
Loading