-
-
Notifications
You must be signed in to change notification settings - Fork 138
/
Copy pathtest_known_fragment_names.py
70 lines (63 loc) · 1.8 KB
/
test_known_fragment_names.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from functools import partial
from graphql.validation import KnownFragmentNamesRule
from .harness import assert_validation_errors
assert_errors = partial(assert_validation_errors, KnownFragmentNamesRule)
assert_valid = partial(assert_errors, errors=[])
def describe_validate_known_fragment_names():
def known_fragment_names_are_valid():
assert_valid(
"""
{
human(id: 4) {
...HumanFields1
... on Human {
...HumanFields2
}
... {
name
}
}
}
fragment HumanFields1 on Human {
name
...HumanFields3
}
fragment HumanFields2 on Human {
name
}
fragment HumanFields3 on Human {
name
}
"""
)
def unknown_fragment_names_are_invalid():
assert_errors(
"""
{
human(id: 4) {
...UnknownFragment1
... on Human {
...UnknownFragment2
}
}
}
fragment HumanFields on Human {
name
...UnknownFragment3
}
""",
[
{
"message": "Unknown fragment 'UnknownFragment1'.",
"locations": [(4, 20)],
},
{
"message": "Unknown fragment 'UnknownFragment2'.",
"locations": [(6, 22)],
},
{
"message": "Unknown fragment 'UnknownFragment3'.",
"locations": [(12, 18)],
},
],
)