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 6
6
SynchronousExecutionMiddleware
7
7
from graphql .core .type import GraphQLSchema as _GraphQLSchema
8
8
from graphql .core .utils .introspection_query import introspection_query
9
+ from graphql .core .utils .schema_printer import print_schema
9
10
10
11
from graphene import signals
11
12
@@ -89,6 +90,9 @@ def objecttype(self, type):
89
90
objecttype ) and issubclass (objecttype , BaseObjectType ):
90
91
return objecttype
91
92
93
+ def __str__ (self ):
94
+ return print_schema (self .schema )
95
+
92
96
def setup (self ):
93
97
assert self .query , 'The base query type is not set'
94
98
self .T (self .query )
Original file line number Diff line number Diff line change @@ -152,3 +152,22 @@ class MyType(ObjectType):
152
152
schema .query = MyType
153
153
154
154
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