nodes: 0, module; 1, function_definition; 2, function_name:get_suggested_type_names; 3, parameters; 4, type; 5, block; 6, typed_parameter; 7, typed_parameter; 8, typed_parameter; 9, generic_type; 10, expression_statement; 11, if_statement; 12, comment:# Otherwise, must be an Object type, which does not have possible fields.; 13, return_statement; 14, identifier:schema; 15, type; 16, identifier:type_; 17, type; 18, identifier:field_name; 19, type; 20, identifier:List; 21, type_parameter; 22, comment:"""
      Get a list of suggested type names.
  
      Go through all of the implementations of type, as well as the interfaces
      that they implement. If any of those types include the provided field,
      suggest them, sorted by how often the type is referenced, starting with
      Interfaces.
      """; 23, call; 24, block; 25, list; 26, identifier:GraphQLSchema; 27, identifier:GraphQLOutputType; 28, identifier:str; 29, type; 30, identifier:is_abstract_type; 31, argument_list; 32, expression_statement; 33, expression_statement; 34, expression_statement; 35, for_statement; 36, comment:# Suggest interface types based on how common they are.; 37, expression_statement; 38, comment:# Suggest both interface and object types.; 39, return_statement; 40, identifier:str; 41, identifier:type_; 42, assignment; 43, assignment; 44, assignment; 45, identifier:possible_type; 46, call; 47, block; 48, assignment; 49, binary_operator:suggested_interface_types + suggested_object_types; 50, identifier:type_; 51, call; 52, identifier:suggested_object_types; 53, list; 54, identifier:interface_usage_count; 55, type; 56, call; 57, attribute; 58, argument_list; 59, if_statement; 60, comment:# This object type defines this field.; 61, expression_statement; 62, for_statement; 63, identifier:suggested_interface_types; 64, call; 65, identifier:suggested_interface_types; 66, identifier:suggested_object_types; 67, identifier:cast; 68, argument_list; 69, generic_type; 70, identifier:defaultdict; 71, argument_list; 72, identifier:schema; 73, identifier:get_possible_types; 74, identifier:type_; 75, comparison_operator:field_name not in possible_type.fields; 76, block; 77, call; 78, identifier:possible_interface; 79, attribute; 80, block; 81, identifier:sorted; 82, argument_list; 83, identifier:GraphQLAbstractType; 84, identifier:type_; 85, identifier:Dict; 86, type_parameter; 87, identifier:int; 88, identifier:field_name; 89, attribute; 90, continue_statement; 91, attribute; 92, argument_list; 93, identifier:possible_type; 94, identifier:interfaces; 95, if_statement; 96, comment:# This interface type defines this field.; 97, expression_statement; 98, identifier:interface_usage_count; 99, keyword_argument; 100, type; 101, type; 102, identifier:possible_type; 103, identifier:fields; 104, identifier:suggested_object_types; 105, identifier:append; 106, attribute; 107, comparison_operator:field_name not in possible_interface.fields; 108, block; 109, augmented_assignment; 110, identifier:key; 111, lambda; 112, identifier:str; 113, identifier:int; 114, identifier:possible_type; 115, identifier:name; 116, identifier:field_name; 117, attribute; 118, continue_statement; 119, subscript; 120, integer:1; 121, lambda_parameters; 122, unary_operator; 123, identifier:possible_interface; 124, identifier:fields; 125, identifier:interface_usage_count; 126, attribute; 127, identifier:k; 128, subscript; 129, identifier:possible_interface; 130, identifier:name; 131, identifier:interface_usage_count; 132, identifier:k
code: def get_suggested_type_names(
      schema: GraphQLSchema, type_: GraphQLOutputType, field_name: str
  ) -> List[str]:
      """
      Get a list of suggested type names.
  
      Go through all of the implementations of type, as well as the interfaces
      that they implement. If any of those types include the provided field,
      suggest them, sorted by how often the type is referenced, starting with
      Interfaces.
      """
      if is_abstract_type(type_):
          type_ = cast(GraphQLAbstractType, type_)
          suggested_object_types = []
          interface_usage_count: Dict[str, int] = defaultdict(int)
          for possible_type in schema.get_possible_types(type_):
              if field_name not in possible_type.fields:
                  continue
              # This object type defines this field.
              suggested_object_types.append(possible_type.name)
              for possible_interface in possible_type.interfaces:
                  if field_name not in possible_interface.fields:
                      continue
                  # This interface type defines this field.
                  interface_usage_count[possible_interface.name] += 1
  
          # Suggest interface types based on how common they are.
          suggested_interface_types = sorted(
              interface_usage_count, key=lambda k: -interface_usage_count[k]
          )
  
          # Suggest both interface and object types.
          return suggested_interface_types + suggested_object_types
  
      # Otherwise, must be an Object type, which does not have possible fields.
      return []