graphql/error/print_error.py
def highlight_source_at_location(source: "Source", location: "SourceLocation") -> str:
    """Highlight source at given location.

    This renders a helpful description of the location of the error in the GraphQL
    Source document.
    """
    first_line_column_offset = source.location_offset.column - 1
    body = " " * first_line_column_offset + source.body

    line_index = location.line - 1
    line_offset = source.location_offset.line - 1
    line_num = location.line + line_offset

    column_offset = first_line_column_offset if location.line == 1 else 0
    column_num = location.column + column_offset

    lines = _re_newline.split(body)  # works a bit different from splitlines()
    len_lines = len(lines)

    def get_line(index: int) -> Optional[str]:
        return lines[index] if 0 <= index < len_lines else None

    return f"{source.name} ({line_num}:{column_num})\n" + print_prefixed_lines(
        [
            (f"{line_num - 1}: ", get_line(line_index - 1)),
            (f"{line_num}: ", get_line(line_index)),
            ("", " " * (column_num - 1) + "^"),
            (f"{line_num + 1}: ", get_line(line_index + 1)),
        ]
    )
Highlight source at given location.

    This renders a helpful description of the location of the error in the GraphQL
    Source document.
    
Highlight source at given location.
This renders a helpful description of the location of the error in the GraphQL
Source document.
Highlight source at given location . This renders a helpful description of the location of the error in the GraphQL Source document .
def highlight_source_at_location(source: "Source", location: "SourceLocation") -> str:
    first_line_column_offset = source.location_offset.column - 1
    body = " " * first_line_column_offset + source.body
    line_index = location.line - 1
    line_offset = source.location_offset.line - 1
    line_num = location.line + line_offset
    column_offset = first_line_column_offset if location.line == 1 else 0
    column_num = location.column + column_offset
    lines = _re_newline.split(body)  
    len_lines = len(lines)
    def get_line(index: int) -> Optional[str]:
        return lines[index] if 0 <= index < len_lines else None
    return f"{source.name} ({line_num}:{column_num})\n" + print_prefixed_lines(
        [
            (f"{line_num - 1}: ", get_line(line_index - 1)),
            (f"{line_num}: ", get_line(line_index)),
            ("", " " * (column_num - 1) + "^"),
            (f"{line_num + 1}: ", get_line(line_index + 1)),
        ]
    )
def highlight_source_at_location ( source : "Source" , location : "SourceLocation" ) -> str : first_line_column_offset = source . location_offset . column - 1 body = " " * first_line_column_offset + source . body line_index = location . line - 1 line_offset = source . location_offset . line - 1 line_num = location . line + line_offset column_offset = first_line_column_offset if location . line == 1 else 0 column_num = location . column + column_offset lines = _re_newline . split ( body ) len_lines = len ( lines ) def get_line ( index : int ) -> Optional [ str ] : return lines [ index ] if 0 <= index < len_lines else None return f"{source.name} ({line_num}:{column_num})\n" + print_prefixed_lines ( [ ( f"{line_num - 1}: " , get_line ( line_index - 1 ) ) , ( f"{line_num}: " , get_line ( line_index ) ) , ( "" , " " * ( column_num - 1 ) + "^" ) , ( f"{line_num + 1}: " , get_line ( line_index + 1 ) ) , ] )
Highlight source at given location.
Highlight source at given location .
"""Highlight source at given location.

    This renders a helpful description of the location of the error in the GraphQL
    Source document.
    """ # works a bit different from splitlines()
source
"Source"
location
"SourceLocation"