Skip to content

Commit 2b56070

Browse files
committed
Add test for legacy fragment with variables
1 parent 9d068ad commit 2b56070

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/starwars/test_dsl.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,3 +1103,30 @@ def test_node_tree_with_loc(ds):
11031103
""".strip()
11041104

11051105
assert node_tree(document, ignore_loc=False) == node_tree_result
1106+
1107+
1108+
def test_legacy_fragment_with_variables(ds):
1109+
var = DSLVariableDefinitions()
1110+
1111+
hero_fragment = (
1112+
DSLFragment("heroFragment")
1113+
.on(ds.Query)
1114+
.select(
1115+
ds.Query.hero.args(episode=var.episode).select(ds.Character.name),
1116+
)
1117+
)
1118+
1119+
print(hero_fragment)
1120+
1121+
hero_fragment.variable_definitions = var
1122+
1123+
query = dsl_gql(hero_fragment)
1124+
1125+
expected = """
1126+
fragment heroFragment($episode: Episode) on Query {
1127+
hero(episode: $episode) {
1128+
name
1129+
}
1130+
}
1131+
""".strip()
1132+
assert print_ast(query) == expected

0 commit comments

Comments
 (0)