7
7
GraphQLArgument ,
8
8
GraphQLBoolean ,
9
9
GraphQLField ,
10
+ GraphQLFieldResolver ,
10
11
GraphQLInt ,
11
12
GraphQLString ,
12
13
GraphQLObjectType ,
22
23
GraphQLInputField ,
23
24
GraphQLNonNull ,
24
25
is_input_type ,
26
+ is_object_type ,
25
27
is_output_type ,
26
28
)
27
29
@@ -114,24 +116,20 @@ def defines_a_query_only_schema():
114
116
BlogSchema = GraphQLSchema (BlogQuery )
115
117
116
118
assert BlogSchema .query_type == BlogQuery
119
+ assert is_object_type (BlogQuery )
117
120
118
121
article_field = BlogQuery .fields ["article" ]
119
122
assert article_field .type == BlogArticle
120
- assert article_field .type .name == "Article"
121
123
122
- article_field_type = article_field .type
123
- assert isinstance (article_field_type , GraphQLObjectType )
124
-
125
- title_field = article_field_type .fields ["title" ]
124
+ assert is_object_type (BlogArticle )
125
+ blog_article_fields = BlogArticle .fields
126
+ title_field = blog_article_fields ["title" ]
126
127
assert title_field .type == GraphQLString
127
- assert title_field .type .name == "String"
128
-
129
- author_field = article_field_type .fields ["author" ]
130
-
131
- author_field_type = author_field .type
132
- assert isinstance (author_field_type , GraphQLObjectType )
133
- recent_article_field = author_field_type .fields ["recentArticle" ]
128
+ author_field = blog_article_fields ["author" ]
129
+ assert author_field .type == BlogAuthor
134
130
131
+ assert is_object_type (BlogAuthor )
132
+ recent_article_field = BlogAuthor .fields ["recentArticle" ]
135
133
assert recent_article_field .type == BlogArticle
136
134
137
135
feed_field = BlogQuery .fields ["feed" ]
@@ -142,9 +140,9 @@ def defines_a_mutation_schema():
142
140
143
141
assert BlogSchema .mutation_type == BlogMutation
144
142
143
+ assert is_object_type (BlogMutation )
145
144
write_mutation = BlogMutation .fields ["writeArticle" ]
146
145
assert write_mutation .type == BlogArticle
147
- assert write_mutation .type .name == "Article"
148
146
149
147
def defines_a_subscription_schema ():
150
148
BlogSchema = GraphQLSchema (query = BlogQuery , subscription = BlogSubscription )
@@ -325,18 +323,18 @@ def allows_a_thunk_for_union_member_types():
325
323
assert types [0 ] is ObjectType
326
324
327
325
def does_not_mutate_passed_field_definitions ():
328
- fields = {
326
+ output_fields = {
329
327
"field1" : GraphQLField (GraphQLString ),
330
328
"field2" : GraphQLField (
331
329
GraphQLString , args = {"id" : GraphQLArgument (GraphQLString )}
332
330
),
333
331
}
334
332
335
- TestObject1 = GraphQLObjectType ("Test1" , fields )
336
- TestObject2 = GraphQLObjectType ("Test2" , fields )
333
+ TestObject1 = GraphQLObjectType ("Test1" , output_fields )
334
+ TestObject2 = GraphQLObjectType ("Test2" , output_fields )
337
335
338
336
assert TestObject1 .fields == TestObject2 .fields
339
- assert fields == {
337
+ assert output_fields == {
340
338
"field1" : GraphQLField (GraphQLString ),
341
339
"field2" : GraphQLField (
342
340
GraphQLString , args = {"id" : GraphQLArgument (GraphQLString )}
@@ -440,7 +438,7 @@ def rejects_an_object_type_with_incorrectly_typed_field_args():
440
438
msg = str (exc_info .value )
441
439
assert msg == "Field args must be a dict with argument names as keys."
442
440
443
- def does_not_accept_is_deprecated_as_argument ():
441
+ def does_not_accept_is_deprecated_instead_of_deprecation_reason_on_field ():
444
442
kwargs = dict (is_deprecated = True )
445
443
with raises (TypeError ) as exc_info :
446
444
GraphQLObjectType (
@@ -514,7 +512,7 @@ def rejects_object_type_with_incorrectly_typed_interfaces_as_a_function():
514
512
515
513
516
514
def describe_type_system_object_fields_must_have_valid_resolve_values ():
517
- def _schema_with_object_with_field_resolver (resolve_value ):
515
+ def _schema_with_object_with_field_resolver (resolve_value : GraphQLFieldResolver ):
518
516
BadResolverType = GraphQLObjectType (
519
517
"BadResolver" ,
520
518
{"bad_field" : GraphQLField (GraphQLString , resolve = resolve_value )},
@@ -843,11 +841,11 @@ def describe_type_system_list_must_accept_only_types():
843
841
844
842
not_types = [{}, dict , str , object , None ]
845
843
846
- @mark .parametrize ("type_" , types )
844
+ @mark .parametrize ("type_" , types , ids = lambda type_ : type_ . __class__ . __name__ )
847
845
def accepts_a_type_as_item_type_of_list (type_ ):
848
846
assert GraphQLList (type_ )
849
847
850
- @mark .parametrize ("type_" , not_types )
848
+ @mark .parametrize ("type_" , not_types , ids = lambda type_ : type_ . __class__ . __name__ )
851
849
def rejects_a_non_type_as_item_type_of_list (type_ ):
852
850
with raises (TypeError ) as exc_info :
853
851
assert GraphQLList (type_ )
0 commit comments