Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add type to app filter
Maciej Korycinski8aad5f3d114c
diff --git a/saleor/graphql/app/filters.py b/saleor/graphql/app/filters.pyindex 78485958cd..f00e1c48ff 100644--- a/saleor/graphql/app/filters.py+++ b/saleor/graphql/app/filters.py@@ -1,7 +1,10 @@import django_filtersfrom ...app import models+from ...app.types import AppType+from ..core.filters import EnumFilterfrom ..utils.filters import filter_by_query_param+from .enums import AppTypeEnumdef filter_app_search(qs, _, value):@@ -10,7 +13,16 @@ def filter_app_search(qs, _, value):return qs+def filter_type(qs, _, value):+ if value == AppType.LOCAL:+ qs = qs.filter(type=AppType.LOCAL)+ elif value == AppType.THIRDPARTY:+ qs = qs.filter(type=AppType.THIRDPARTY)+ return qs++class AppFilter(django_filters.FilterSet):+ type = EnumFilter(input_class=AppTypeEnum, method=filter_type)search = django_filters.CharFilter(method=filter_app_search)is_active = django_filters.BooleanFilter()diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 67ebb3dab3..0b5de901f7 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -287,6 +287,7 @@ type AppFetchManifest {input AppFilterInput {search: StringisActive: Boolean+ type: AppTypeEnum}input AppInput {diff --git a/tests/api/app/queries/test_apps.py b/tests/api/app/queries/test_apps.pyindex 798058ce94..0e90a0c57d 100644--- a/tests/api/app/queries/test_apps.py+++ b/tests/api/app/queries/test_apps.py@@ -2,6 +2,7 @@ import pytestfrom freezegun import freeze_timefrom saleor.app.models import App+from saleor.graphql.app.enums import AppTypeEnumfrom saleor.webhook.models import Webhookfrom ...utils import assert_no_permission, get_graphql_content@@ -40,7 +41,14 @@ QUERY_APPS_WITH_FILTER = """@pytest.mark.parametrize(- "app_filter, count", (({"search": "Sample"}, 1), ({"isActive": False}, 1), ({}, 2)),+ "app_filter, count",+ (+ ({"search": "Sample"}, 1),+ ({"isActive": False}, 1),+ ({}, 2),+ ({"type": AppTypeEnum.THIRDPARTY.name}, 1),+ ({"type": AppTypeEnum.LOCAL.name}, 1),+ ),)def test_apps_query(staff_api_client,