Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Lower _resolve_nodes complexity
NyanKiyoshiceb37a0f7e89
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0191bfd217..0476c31681 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,6 +9,8 @@ All notable, unreleased changes to this project will be documented in this file.- Fix dashboard 1.0 missing logo and missing back arrow on collections - #3958 by @NyanKiyoshi- Add mutations for publishing and unpublishing multiple pages - #3954 by @akjanik+- Cleanup and maintenance of the GraphQL API code - #3942 by @NyanKiyoshi+## 2.5.0### APIdiff --git a/saleor/graphql/utils.py b/saleor/graphql/utils.pyindex 51cb42ac6c..bd922194ee 100644--- a/saleor/graphql/utils.py+++ b/saleor/graphql/utils.py@@ -24,24 +24,31 @@ def get_database_id(info, node_id, only_type):return _id+def _check_graphene_type(requested_graphene_type, received_type):+ if requested_graphene_type:+ assert str(requested_graphene_type) == received_type, (+ 'Must receive an {} id.'+ ).format(requested_graphene_type._meta.name)++def _resolve_nodes(ids, graphene_type=None):pks = []types = []invalid_ids = []for graphql_id in ids:- if graphql_id:- try:- _type, _id = from_global_id(graphql_id)- except Exception:- invalid_ids.append(graphql_id)- else:- if graphene_type:- assert str(graphene_type) == _type, (- 'Must receive an {} id.').format(- graphene_type._meta.name)- pks.append(_id)- types.append(_type)+ if not graphql_id:+ continue++ try:+ _type, _id = from_global_id(graphql_id)+ except Exception:+ invalid_ids.append(graphql_id)+ continue++ _check_graphene_type(graphene_type, _type)+ pks.append(_id)+ types.append(_type)if invalid_ids:raise GraphQLError(