File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 66 SynchronousExecutionMiddleware
77from graphql .core .type import GraphQLSchema as _GraphQLSchema
88from graphql .core .utils .introspection_query import introspection_query
9+ from graphql .core .utils .schema_printer import print_schema
910
1011from graphene import signals
1112
@@ -89,6 +90,9 @@ def objecttype(self, type):
8990 objecttype ) and issubclass (objecttype , BaseObjectType ):
9091 return objecttype
9192
93+ def __str__ (self ):
94+ return print_schema (self .schema )
95+
9296 def setup (self ):
9397 assert self .query , 'The base query type is not set'
9498 self .T (self .query )
Original file line number Diff line number Diff line change @@ -152,3 +152,22 @@ class MyType(ObjectType):
152152 schema .query = MyType
153153
154154 assert schema .T (t ) == schema .T (MyType )
155+
156+
157+ def test_schema_str ():
158+ expected = """
159+ interface Character {
160+ name: String
161+ }
162+
163+ type Human implements Character {
164+ name: String
165+ friends: [Character]
166+ pet: Pet
167+ }
168+
169+ type Pet {
170+ type: String
171+ }
172+ """ .lstrip ()
173+ assert str (schema ) == expected
You can’t perform that action at this time.
0 commit comments