Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Unify attribute inputs

Pacu2aa064f3450c9
diff --git a/saleor/graphql/product/mutations/attributes.py b/saleor/graphql/product/mutations/attributes.py
index 9f016b84d1..2f88c288cd 100644
--- a/saleor/graphql/product/mutations/attributes.py
+++ b/saleor/graphql/product/mutations/attributes.py
@@ -18,18 +18,14 @@ class AttributeValueCreateInput(graphene.InputObjectType):
required=True, description='Real value eg. HEX color.')
-class AttributeValueUpdateInput(graphene.InputObjectType):
+class AttributeInput(graphene.InputObjectType):
slug = graphene.String(
required=True, description='Internal name.')
name = graphene.String(
required=True, description='Name displayed in the interface.')
-class AttributeCreateInput(graphene.InputObjectType):
- slug = graphene.String(
- required=True, description='Internal name.')
- name = graphene.String(
- required=True, description='Name displayed in the interface.')
+class AttributeCreateInput(AttributeInput):
values = graphene.List(
AttributeValueCreateInput,
description='Attribute values to be created for this attribute.')
@@ -80,18 +76,11 @@ class AttributeCreate(ModelMutation):
instance.values.create(**value)
-class AttributesInput(graphene.InputObjectType):
- slug = graphene.String(
- required=True, description='Internal name.')
- name = graphene.String(
- required=True, description='Name displayed in the interface.')
-
-
class AttributeUpdate(AttributeCreate):
class Arguments:
id = graphene.ID(
required=True, description='ID of an attribute to update.')
- input = AttributesInput(
+ input = AttributeInput(
required=True,
description='Fields required to update an attribute.')
@@ -134,7 +123,7 @@ class AttributeValueUpdate(AttributeValueCreate):
id = graphene.ID(
required=True,
description='ID of an attribute choice value to update.')
- input = AttributeValueUpdateInput(
+ input = AttributeInput(
required=True,
description='Fields required to update an attribute choice value.')
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 9490c8385d..bcae7ea85d 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -389,6 +389,11 @@ type AttributeDelete {
attribute: Attribute
}
+input AttributeInput {
+ slug: String!
+ name: String!
+}
+
scalar AttributeScalar
type AttributeUpdate {
@@ -439,16 +444,6 @@ type AttributeValueUpdate {
attributeValue: AttributeValue
}
-input AttributeValueUpdateInput {
- slug: String!
- name: String!
-}
-
-input AttributesInput {
- slug: String!
- name: String!
-}
-
type AuthorizationKey {
name: String!
key: String!
@@ -901,7 +896,7 @@ type Mutations {
passwordReset(email: String!): PasswordReset
attributeValueCreate(input: AttributeValueCreateInput!): AttributeValueCreate
attributeValueDelete(id: ID!): AttributeValueDelete
- attributeValueUpdate(id: ID!, input: AttributeValueUpdateInput!): AttributeValueUpdate
+ attributeValueUpdate(id: ID!, input: AttributeInput!): AttributeValueUpdate
categoryCreate(input: CategoryInput!): CategoryCreate
categoryDelete(id: ID!): CategoryDelete
categoryUpdate(id: ID!, input: CategoryInput!): CategoryUpdate
@@ -949,7 +944,7 @@ type Mutations {
pageUpdate(id: ID!, input: PageInput!): PageUpdate
attributeCreate(input: AttributeCreateInput!): AttributeCreate
attributeDelete(id: ID!): AttributeDelete
- attributeUpdate(id: ID!, input: AttributesInput!): AttributeUpdate
+ attributeUpdate(id: ID!, input: AttributeInput!): AttributeUpdate
productCreate(input: ProductCreateInput!): ProductCreate
productDelete(id: ID!): ProductDelete
productUpdate(id: ID!, input: ProductInput!): ProductUpdate
diff --git a/tests/api/test_attributes.py b/tests/api/test_attributes.py
index e8ce501cce..50bdc0a0ab 100644
--- a/tests/api/test_attributes.py
+++ b/tests/api/test_attributes.py
@@ -161,7 +161,7 @@ def test_create_attribute_and_attribute_values_errors(admin_api_client):
assert errors
assert errors[0]['field'] == 'values'
assert errors[0]['message'] == 'Duplicated attribute value names provided.'
- assert errors[1]['field'] == 'values-slug'
+ assert errors[1]['field'] == 'values:slug'
assert errors[1]['message'] == (
'Enter a valid \'slug\' consisting of letters, '
'numbers, underscores or hyphens.')