code: def get_referenced_fields_and_fragment_names(
      context: ValidationContext,
      cached_fields_and_fragment_names: Dict,
      fragment: FragmentDefinitionNode,
  ) -> Tuple[NodeAndDefCollection, List[str]]:
      
      # Short-circuit building a type from the node if possible.
      cached = cached_fields_and_fragment_names.get(fragment.selection_set)
      if cached:
          return cached
  
      fragment_type = type_from_ast(context.schema, fragment.type_condition)
      return get_fields_and_fragment_names(
          context, cached_fields_and_fragment_names, fragment_type, fragment.selection_set
      )
docs: Get referenced fields and nested fragment names
  
      Given a reference to a fragment, return the represented collection of fields as well
      as a list of nested fragment names referenced via fragment spreads.