| 1 |
from itertools import chain |
| 2 |
from typing import Collection |
| 3 |
|
| 4 |
from ..language.ast import DocumentNode |
| 5 |
|
| 6 |
__all__ = ["concat_ast"] |
| 7 |
|
| 8 |
|
| 9 |
def concat_ast(asts: Collection[DocumentNode]) -> DocumentNode: |
| 10 |
"""Concat ASTs. |
| 11 |
|
| 12 |
Provided a collection of ASTs, presumably each from different files, concatenate |
| 13 |
the ASTs together into batched AST, useful for validating many GraphQL source files |
| 14 |
which together represent one conceptual application. |
| 15 |
""" |
| 16 |
return DocumentNode( |
| 17 |
definitions=list(chain.from_iterable(document.definitions for document in asts)) |
| 18 |
) |