File tree 3 files changed +23
-1
lines changed
3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ a query language for APIs created by Facebook.
13
13
[ ![ Code Style] ( https://img.shields.io/badge/code%20style-black-000000.svg )] ( https://github.com/ambv/black )
14
14
15
15
The current version 1.0.2 of GraphQL-core-next is up-to-date with GraphQL.js version
16
- 14.2.1. All parts of the API are covered by an extensive test suite of currently 1742
16
+ 14.2.1. All parts of the API are covered by an extensive test suite of currently 1746
17
17
unit tests.
18
18
19
19
Original file line number Diff line number Diff line change @@ -446,6 +446,12 @@ def __init__(
446
446
self .description = description
447
447
self .ast_node = ast_node
448
448
449
+ def __repr__ (self ):
450
+ return f"<{ self .__class__ .__name__ } { self .type !r} >"
451
+
452
+ def __str__ (self ):
453
+ return f"Field: { self .type } "
454
+
449
455
def __eq__ (self , other ):
450
456
return self is other or (
451
457
isinstance (other , GraphQLField )
Original file line number Diff line number Diff line change 10
10
GraphQLField ,
11
11
GraphQLInputField ,
12
12
GraphQLInputObjectType ,
13
+ GraphQLInt ,
13
14
GraphQLInterfaceType ,
14
15
GraphQLList ,
15
16
GraphQLNonNull ,
16
17
GraphQLObjectType ,
17
18
GraphQLScalarType ,
19
+ GraphQLString ,
18
20
GraphQLUnionType ,
19
21
)
20
22
@@ -628,3 +630,17 @@ def simple_types_have_repr():
628
630
repr (GraphQLList (ListOfScalarsType ))
629
631
== "<GraphQLList <GraphQLList <GraphQLScalarType 'Scalar'>>>"
630
632
)
633
+
634
+ def stringifies_fields ():
635
+ assert str (GraphQLField (GraphQLNonNull (GraphQLString ))) == "Field: String!"
636
+ assert str (GraphQLField (GraphQLList (GraphQLInt ))) == "Field: [Int]"
637
+
638
+ def fields_have_repr ():
639
+ assert (
640
+ repr (GraphQLField (GraphQLNonNull (GraphQLString )))
641
+ == "<GraphQLField <GraphQLNonNull <GraphQLScalarType 'String'>>>"
642
+ )
643
+ assert (
644
+ repr (GraphQLField (GraphQLList (GraphQLInt )))
645
+ == "<GraphQLField <GraphQLList <GraphQLScalarType 'Int'>>>"
646
+ )
You can’t perform that action at this time.
0 commit comments