File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ import itertools
2+
3+ from ..language .ast import Document
4+
5+
6+ def concat_ast (asts ):
7+ return Document (definitions = list (itertools .chain .from_iterable (
8+ document .definitions for document in asts
9+ )))
Original file line number Diff line number Diff line change 1+ from graphql .core import Source , parse
2+
3+ from graphql .core .language .printer import print_ast
4+ from graphql .core .utils .concat_ast import concat_ast
5+
6+
7+ def test_it_concatenates_two_acts_together ():
8+ source_a = Source ('{ a, b, ... Frag }' )
9+ source_b = Source ('''
10+ fragment Frag on T {
11+ c
12+ }
13+ ''' )
14+
15+ ast_a = parse (source_a )
16+ ast_b = parse (source_b )
17+ ast_c = concat_ast ([ast_a , ast_b ])
18+
19+ assert print_ast (ast_c ) == '''{
20+ a
21+ b
22+ ...Frag
23+ }
24+
25+ fragment Frag on T {
26+ c
27+ }
28+ '''
You can’t perform that action at this time.
0 commit comments