async def _execute_children( self, execution_ctx: "ExecutionContext", request_ctx: Optional[Dict[str, Any]], result: Optional[Any], coerced: Optional[Any], ) -> None: coroutz = [] if self.shall_produce_list: # TODO Better manage of None values here. (Should be transformed by coerce) if isinstance(result, list) and isinstance(coerced, list): for index, raw in enumerate(result): raw_typename = get_typename(raw) coroutz = coroutz + self._get_coroutz_from_child( execution_ctx, request_ctx, raw, coerced[index], raw_typename, ) else: raw_typename = get_typename(result) coroutz = self._get_coroutz_from_child(execution_ctx, request_ctx, result, coerced, raw_typename) await asyncio.gather(*coroutz, return_exceptions=False)
async def __typename_resolver( parent_result: Optional[Any], _args: Dict[str, Any], _ctx: Optional[Dict[str, Any]], info: "Info", ) -> "GraphQLType": try: return info.schema_field.schema.find_type(get_typename(parent_result)) except (AttributeError, KeyError): pass return info.schema_field.parent_type
def test_coercer_factory__set_typename(res, typename, expected): from tartiflette.utils.coercer import _set_typename from tartiflette.types.helpers import get_typename assert _set_typename(res, typename) is None assert get_typename(res) == expected
def test_resolver_factory__set_typename(res, typename, expected): from tartiflette.resolver.factory import _set_typename from tartiflette.types.helpers import get_typename assert _set_typename(res, typename) is None assert get_typename(res) == expected