Refactor resolver map decomposing
from collections import defaultdict
-from typing import Iterable, List, Dict, Union, Generator, Tuple, Any
+from itertools import chain
+from typing import List, Union
from graphql import GraphQLSchema
@@ -7,16 +8,13 @@ from .build_schema import build_schema_from_type_definitions
from .resolvers import add_resolve_functions_to_schema
-def flatten_map(resolver_map):
- for key, value in resolver_map.items():
+def decompose_maps(resolvers_map):
+ def flatten(rm):
+ for key, value in rm.items():
for resolver_name, resolver in value.items():
yield (key, resolver_name, resolver)
-
-def decompose_maps(resolver_maps):
- for r_map in resolver_maps:
- for item in flatten_map(r_map):
- yield item
+ return chain.from_iterable(flatten(m) for m in resolvers_map)
def merge_resolvers(resolver_list):
