Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Rename _resolve_nodes and add typing in csv export mutations file
IKarbowiak306defe01bd3
diff --git a/saleor/graphql/csv/mutations.py b/saleor/graphql/csv/mutations.pyindex cf19c8b1fd..3fe49a549b 100644--- a/saleor/graphql/csv/mutations.py+++ b/saleor/graphql/csv/mutations.py@@ -1,3 +1,5 @@+from typing import Dict, List, Mapping, Union+import graphenefrom django.core.exceptions import ValidationError@@ -9,7 +11,7 @@ from ..core.mutations import BaseMutationfrom ..core.types.common import CsvErrorfrom ..product.filters import ProductFilterInputfrom ..product.types import Product-from ..utils import _resolve_nodes+from ..utils import resolve_global_ids_to_primary_keysfrom .enums import ExportScopefrom .types import Job@@ -54,16 +56,16 @@ class ExportProducts(BaseMutation):return cls(job=job)@classmethod- def get_products_scope(cls, info, input):+ def get_products_scope(cls, info, input) -> Mapping[str, Union[list, dict, str]]:scope = input["scope"]- if scope == ExportScope.IDS.value:+ if scope == ExportScope.IDS.value: # type: ignorereturn cls.clean_ids(input)- elif scope == ExportScope.FILTER.value:+ elif scope == ExportScope.FILTER.value: # type: ignorereturn cls.clean_filter(input)return {"all": ""}@staticmethod- def clean_ids(input):+ def clean_ids(input) -> Dict[str, List[str]]:ids = input.get("ids", [])if not ids:raise ValidationError(@@ -74,11 +76,11 @@ class ExportProducts(BaseMutation):)})- _, pks = _resolve_nodes(ids, graphene_type=Product)+ _, pks = resolve_global_ids_to_primary_keys(ids, graphene_type=Product)return {"ids": pks}@staticmethod- def clean_filter(input):+ def clean_filter(input) -> Dict[str, dict]:filter = input.get("filter")if not filter:raise ValidationError(diff --git a/saleor/graphql/utils.py b/saleor/graphql/utils.pyindex 6dca88f7dc..6e38884ffc 100644--- a/saleor/graphql/utils.py+++ b/saleor/graphql/utils.py@@ -32,7 +32,7 @@ def _check_graphene_type(requested_graphene_type, received_type):).format(str(requested_graphene_type))-def _resolve_nodes(ids, graphene_type=None):+def resolve_global_ids_to_primary_keys(ids, graphene_type=None):pks = []invalid_ids = []used_type = graphene_type@@ -76,7 +76,7 @@ def get_nodes(If the `graphene_type` is of type str, the model keyword argument must be provided."""- nodes_type, pks = _resolve_nodes(ids, graphene_type)+ nodes_type, pks = resolve_global_ids_to_primary_keys(ids, graphene_type)# If `graphene_type` was not provided, check if all resolved types are# the same. This prevents from accidentally mismatching IDs of different