1
+ import inspect
1
2
2
3
from graphql import GraphQLSchema , graphql , is_type
3
4
from graphql .type .directives import (GraphQLDirective , GraphQLIncludeDirective ,
7
8
from graphql .utils .schema_printer import print_schema
8
9
9
10
from .definitions import GrapheneGraphQLType
11
+ from .objecttype import ObjectType
10
12
from .typemap import TypeMap , is_graphene_type
11
13
12
14
@@ -20,6 +22,9 @@ class Schema(GraphQLSchema):
20
22
21
23
def __init__ (self , query = None , mutation = None , subscription = None ,
22
24
directives = None , types = None , auto_camelcase = True ):
25
+ assert inspect .isclass (query ) and issubclass (query , ObjectType ), (
26
+ 'Schema query must be Object Type but got: {}.'
27
+ ).format (query )
23
28
self ._query = query
24
29
self ._mutation = mutation
25
30
self ._subscription = subscription
@@ -77,7 +82,10 @@ def execute(self, *args, **kwargs):
77
82
return graphql (self , * args , ** kwargs )
78
83
79
84
def introspect (self ):
80
- return self .execute (introspection_query ).data
85
+ instrospection = self .execute (introspection_query )
86
+ if instrospection .errors :
87
+ raise instrospection .errors [0 ]
88
+ return instrospection .data
81
89
82
90
def __str__ (self ):
83
91
return print_schema (self )
0 commit comments