Skip to content

Commit 365a92c

Browse files
committed
update schema printer tests
1 parent 816f67c commit 365a92c

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

graphql/utils/tests/test_schema_printer.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,22 @@ def test_prints_string_field_with_int_arg_with_default():
156156
'''
157157

158158

159+
def test_prints_string_field_with_int_arg_with_default_null():
160+
output = print_single_field_schema(GraphQLField(
161+
type=GraphQLString,
162+
args={'argOne': GraphQLArgument(GraphQLInt, default_value=None)}
163+
))
164+
assert output == '''
165+
schema {
166+
query: Root
167+
}
168+
169+
type Root {
170+
singleField(argOne: Int = null): String
171+
}
172+
'''
173+
174+
159175
def test_prints_string_field_with_non_null_int_arg():
160176
output = print_single_field_schema(GraphQLField(
161177
type=GraphQLString,
@@ -455,6 +471,72 @@ def test_prints_input_type():
455471
'''
456472

457473

474+
def test_prints_input_type_with_default():
475+
InputType = GraphQLInputObjectType(
476+
name='InputType',
477+
fields={
478+
'int': GraphQLInputObjectField(GraphQLInt, default_value=2)
479+
}
480+
)
481+
482+
Root = GraphQLObjectType(
483+
name='Root',
484+
fields={
485+
'str': GraphQLField(GraphQLString, args={'argOne': GraphQLArgument(InputType)})
486+
}
487+
)
488+
489+
Schema = GraphQLSchema(Root)
490+
output = print_for_test(Schema)
491+
492+
assert output == '''
493+
schema {
494+
query: Root
495+
}
496+
497+
input InputType {
498+
int: Int = 2
499+
}
500+
501+
type Root {
502+
str(argOne: InputType): String
503+
}
504+
'''
505+
506+
507+
def test_prints_input_type_with_default_null():
508+
InputType = GraphQLInputObjectType(
509+
name='InputType',
510+
fields={
511+
'int': GraphQLInputObjectField(GraphQLInt, default_value=None)
512+
}
513+
)
514+
515+
Root = GraphQLObjectType(
516+
name='Root',
517+
fields={
518+
'str': GraphQLField(GraphQLString, args={'argOne': GraphQLArgument(InputType)})
519+
}
520+
)
521+
522+
Schema = GraphQLSchema(Root)
523+
output = print_for_test(Schema)
524+
525+
assert output == '''
526+
schema {
527+
query: Root
528+
}
529+
530+
input InputType {
531+
int: Int = null
532+
}
533+
534+
type Root {
535+
str(argOne: InputType): String
536+
}
537+
'''
538+
539+
458540
def test_prints_custom_scalar():
459541
OddType = GraphQLScalarType(
460542
name='Odd',

0 commit comments

Comments
 (0)