Skip to content

Commit e52093e

Browse files
committed
Add tests for directives on anonymous inline fragments.
1 parent 5b190d3 commit e52093e

File tree

1 file changed

+56
-1
lines changed

1 file changed

+56
-1
lines changed

tests/core_execution/test_directives.py

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from graphql.core.language.parser import parse
33
from graphql.core.type import GraphQLSchema, GraphQLObjectType, GraphQLField, GraphQLString
44

5-
65
schema = GraphQLSchema(
76
query=GraphQLObjectType(
87
name='TestType',
@@ -239,3 +238,59 @@ def test_skip_true_omits_fragment():
239238
result = execute_test_query(q)
240239
assert not result.errors
241240
assert result.data == {'a': 'a'}
241+
242+
243+
def test_skip_on_inline_anonymous_fragment_omits_field():
244+
q = '''
245+
query Q {
246+
a
247+
... @skip(if: true) {
248+
b
249+
}
250+
}
251+
'''
252+
result = execute_test_query(q)
253+
assert not result.errors
254+
assert result.data == {'a': 'a'}
255+
256+
257+
def test_skip_on_inline_anonymous_fragment_does_not_omit_field():
258+
q = '''
259+
query Q {
260+
a
261+
... @skip(if: false) {
262+
b
263+
}
264+
}
265+
'''
266+
result = execute_test_query(q)
267+
assert not result.errors
268+
assert result.data == {'a': 'a', 'b': 'b'}
269+
270+
271+
def test_include_on_inline_anonymous_fragment_omits_field():
272+
q = '''
273+
query Q {
274+
a
275+
... @include(if: false) {
276+
b
277+
}
278+
}
279+
'''
280+
result = execute_test_query(q)
281+
assert not result.errors
282+
assert result.data == {'a': 'a'}
283+
284+
285+
def test_include_on_inline_anonymous_fragment_does_not_omit_field():
286+
q = '''
287+
query Q {
288+
a
289+
... @include(if: true) {
290+
b
291+
}
292+
}
293+
'''
294+
result = execute_test_query(q)
295+
assert not result.errors
296+
assert result.data == {'a': 'a', 'b': 'b'}

0 commit comments

Comments
 (0)