Skip to content

Commit

Permalink
Fix choices resolver on Attribute type (#7597)
Browse files Browse the repository at this point in the history
  • Loading branch information
IKarbowiak committed Jul 12, 2021
1 parent 6ec684e commit 9863a71
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_get_single_attribute_by_slug_as_customer(


QUERY_ATTRIBUTE = """
query($id: ID!) {
query($id: ID!, $query: String) {
attribute(id: $id) {
id
slug
Expand All @@ -71,7 +71,7 @@ def test_get_single_attribute_by_slug_as_customer(
entityType
type
unit
choices(first: 10) {
choices(first: 10, filter: {search: $query}) {
edges {
node {
slug
Expand Down Expand Up @@ -280,7 +280,7 @@ def test_get_single_reference_attribute_by_staff(
)
query = QUERY_ATTRIBUTE
content = get_graphql_content(
staff_api_client.post_graphql(query, {"id": attribute_gql_id})
staff_api_client.post_graphql(query, {"id": attribute_gql_id, "query": ""})
)

assert content["data"]["attribute"], "Should have found an attribute"
Expand Down Expand Up @@ -317,6 +317,7 @@ def test_get_single_reference_attribute_by_staff(
content["data"]["attribute"]["entityType"]
== product_type_page_reference_attribute.entity_type.upper()
)
assert not content["data"]["attribute"]["choices"]["edges"]


def test_get_single_numeric_attribute_by_staff(
Expand Down
2 changes: 1 addition & 1 deletion saleor/graphql/attribute/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class Meta:
def resolve_choices(root: models.Attribute, info, **_kwargs):
if root.input_type in AttributeInputType.TYPES_WITH_CHOICES:
return root.values.all()
return []
return models.AttributeValue.objects.none()

@staticmethod
@check_attribute_required_permissions()
Expand Down

0 comments on commit 9863a71

Please sign in to comment.