# Buggy code
def register_sdl(
    schema_name: str,
    sdl: Union[str, List[str], GraphQLSchema],
    exclude_builtins_scalars: Optional[List[str]] = None,
) -> None:
    SchemaRegistry._schemas.setdefault(schema_name, {})

    # Maybe read them one and use them a lot :p
    sdl_files_list = _get_builtins_sdl_files(exclude_builtins_scalars)

    full_sdl = ""

    if isinstance(sdl, list):
        sdl_files_list += sdl
    elif os.path.isfile(sdl):
        sdl_files_list.append(sdl)
    elif os.path.isdir(sdl):
        sdl_files_list += glob(os.path.join(sdl, "**/*.sdl"), recursive=True) + glob(
            os.path.join(sdl, "**/*.graphql"), recursive=True
        )
    else:
        full_sdl = sdl

    # Convert SDL files into big schema and parse it
    for filepath in sdl_files_list:
        with open(filepath, "r") as sdl_file:
            full_sdl += " " + sdl_file.read().replace("\n", " ")

    SchemaRegistry._schemas[schema_name]["sdl"] = full_sdl


# Traceback (lark.exceptions.UnexpectedToken)
Traceback (most recent call last):
File "/home/bkc/PythonEnvironments/SFI.Projects.EntryWizard/bin/manifest-graphql", line 11, in <module>
load_entry_point('entry-wizard', 'console_scripts', 'manifest-graphql')()
File "/home/bkc/src/SFI/SFI.Projects.EntryWizard/entry_wizard/manifest_system/scripts/graphql_server.py", line 12, in main
result = run()
File "/home/bkc/src/SFI/SFI.Projects.EntryWizard/entry_wizard/graphql/server/app.py", line 59, in run
engine = get_engine(schema_folder=schema_folder)
File "/home/bkc/src/SFI/SFI.Projects.EntryWizard/entry_wizard/graphql/server/app.py", line 27, in get_engine
"entry_wizard.graphql.resolvers.vendor",
File "/home/bkc/PythonEnvironments/SFI.Projects.EntryWizard/lib/python3.7/site-packages/tartiflette/engine.py", line 57, in __init__
schema_name, custom_default_resolver, exclude_builtins_scalars
File "/home/bkc/PythonEnvironments/SFI.Projects.EntryWizard/lib/python3.7/site-packages/tartiflette/schema/bakery.py", line 41, in bake
schema = SchemaBakery._preheat(schema_name, exclude_builtins_scalars)
File "/home/bkc/PythonEnvironments/SFI.Projects.EntryWizard/lib/python3.7/site-packages/tartiflette/schema/bakery.py", line 21, in _preheat
build_graphql_schema_from_sdl(sdl, schema=schema)
File "/home/bkc/PythonEnvironments/SFI.Projects.EntryWizard/lib/python3.7/site-packages/tartiflette/sdl/builder.py", line 30, in build_graphql_schema_from_sdl
sdl, parse_graphql_sdl_to_ast(sdl), schema=schema
File "/home/bkc/PythonEnvironments/SFI.Projects.EntryWizard/lib/python3.7/site-packages/tartiflette/sdl/builder.py", line 53, in parse_graphql_sdl_to_ast
return gqlsdl(sdl)
File "/home/bkc/PythonEnvironments/SFI.Projects.EntryWizard/lib/python3.7/site-packages/lark/lark.py", line 223, in parse
return self.parser.parse(text)
File "/home/bkc/PythonEnvironments/SFI.Projects.EntryWizard/lib/python3.7/site-packages/lark/parser_frontends.py", line 38, in parse
return self.parser.parse(token_stream, *[sps] if sps is not NotImplemented else [])
File "/home/bkc/PythonEnvironments/SFI.Projects.EntryWizard/lib/python3.7/site-packages/lark/parsers/lalr_parser.py", line 82, in parse
_action, arg = get_action('$END')
File "/home/bkc/PythonEnvironments/SFI.Projects.EntryWizard/lib/python3.7/site-packages/lark/parsers/lalr_parser.py", line 49, in get_action
raise UnexpectedToken(token, expected, state=state)  # TODO filter out rules from expected
lark.exceptions.UnexpectedToken: Unexpected token Token(BANG, '!') at line 1, column 3985.
Expected: SCHEMA, IDENT, TYPE, UNION, SCALAR, INTERFACE, MUTATION, RPAR, ENUM, STRING, QUERY, INPUT, LONG_STRING, TYPE_SYSTEM_DIRECTIVE_LOCATION, IMPLEMENTS, AT, EQUAL, DIRECTIVE, SUBSCRIPTION, RBRACE, EXTEND, ON, RSQB

# Fixed code
def register_sdl(
    schema_name: str,
    sdl: Union[str, List[str], GraphQLSchema],
    exclude_builtins_scalars: Optional[List[str]] = None,
) -> None:
    SchemaRegistry._schemas.setdefault(schema_name, {})

    # Maybe read them one and use them a lot :p
    sdl_files_list = _get_builtins_sdl_files(exclude_builtins_scalars)

    full_sdl = ""

    if isinstance(sdl, list):
        sdl_files_list += sdl
    elif os.path.isfile(sdl):
        sdl_files_list.append(sdl)
    elif os.path.isdir(sdl):
        sdl_files_list += glob(os.path.join(sdl, "**/*.sdl"), recursive=True) + glob(
            os.path.join(sdl, "**/*.graphql"), recursive=True
        )
    else:
        full_sdl = sdl

    # Convert SDL files into big schema and parse it
    for filepath in sdl_files_list:
        with open(filepath, "r") as sdl_file:
            full_sdl += "\n" + sdl_file.read()

    SchemaRegistry._schemas[schema_name]["sdl"] = full_sdl