import re

from graphql.language import parse


GQL_SCHEMA_TYPE = r"(?si)^Schema.*?}"


def convert_to_ast(sdl: str):
    """Parse the content of files to AST"""
    # Replace schema {} with empty string, it will be generated by the server
    sdl = re.sub(GQL_SCHEMA_TYPE, "", sdl)
    return parse(sdl)
