Remove local type hints and simplyfy code
from collections import defaultdict
-from typing import List, Union
+from typing import Iterable, List, Dict, Union, Generator, Tuple, Any
from graphql import GraphQLSchema
@@ -7,22 +7,22 @@ from .build_schema import build_schema_from_type_definitions
from .resolvers import add_resolve_functions_to_schema
-def flatten_map(resolver_map: dict) -> List[tuple]:
+def flatten_map(resolver_map):
for key, value in resolver_map.items():
for resolver_name, resolver in value.items():
yield (key, resolver_name, resolver)
-def decompose_maps(resolver_maps: List[dict]) -> List[tuple]:
+def decompose_maps(resolver_maps):
for r_map in resolver_maps:
for item in flatten_map(r_map):
yield item
-def merge_resolvers(resolver_list: List[tuple]) -> dict:
+def merge_resolvers(resolver_list):
output = defaultdict(dict)
for key, resolver_name, resolver in resolver_list:
- output[key].update({resolver_name: resolver})
+ output[key][resolver_name] = resolver
return output
