Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Return attributes global id instead of db pk
Krzysztof Świątekf4827f43c6e1
diff --git a/saleor/graphql/product/mutations/attributes.py b/saleor/graphql/product/mutations/attributes.pyindex daf8a1f6e9..cd56c73ebd 100644--- a/saleor/graphql/product/mutations/attributes.py+++ b/saleor/graphql/product/mutations/attributes.py@@ -405,6 +405,9 @@ class AttributeAssign(BaseMutation):)if len(attrs_pk) != len(attributes):invalid_attrs = set(attrs_pk) - set(attributes)+ invalid_attrs = [+ graphene.Node.to_global_id("Attribute", pk) for pk in invalid_attrs+ ]raise ValidationError({"operations": ValidationError(diff --git a/tests/api/test_attributes.py b/tests/api/test_attributes.pyindex ff2c7623b0..98160bb423 100644--- a/tests/api/test_attributes.py+++ b/tests/api/test_attributes.py@@ -1187,6 +1187,7 @@ ASSIGN_ATTR_QUERY = """fieldcodemessage+ attributes}productType {id@@ -1260,9 +1261,8 @@ def test_assign_non_existing_attributes_to_product_type(product_type_global_id = graphene.Node.to_global_id("ProductType", product_type.pk)query = ASSIGN_ATTR_QUERY- operations = [- {"type": "PRODUCT", "id": graphene.Node.to_global_id("Attribute", "555")}- ]+ attribute_id = graphene.Node.to_global_id("Attribute", "555")+ operations = [{"type": "PRODUCT", "id": attribute_id}]variables = {"productTypeId": product_type_global_id, "operations": operations}response = staff_api_client.post_graphql(@@ -1272,6 +1272,7 @@ def test_assign_non_existing_attributes_to_product_type(content = content["data"]["attributeAssign"]assert content["productErrors"][0]["code"] == ProductErrorCode.NOT_FOUND.nameassert content["productErrors"][0]["field"] == "operations"+ assert content["productErrors"][0]["attributes"] == [attribute_id]def test_assign_variant_attribute_to_product_type_with_disabled_variants(