@@ -24,16 +24,21 @@ class GraphQLSchema(object):
2424 mutation=MyAppMutationRootType
2525 )
2626 """
27- __slots__ = '_query' , '_mutation' , '_type_map' , '_directives'
27+ __slots__ = '_query' , '_mutation' , '_subscription' , ' _type_map' , '_directives' ,
2828
29- def __init__ (self , query , mutation = None ):
29+ def __init__ (self , query , mutation = None , subscription = None ):
3030 assert isinstance (query , GraphQLObjectType ), 'Schema query must be Object Type but got: {}.' .format (query )
3131 if mutation :
3232 assert isinstance (mutation , GraphQLObjectType ), \
3333 'Schema mutation must be Object Type but got: {}.' .format (mutation )
3434
35+ if subscription :
36+ assert isinstance (subscription , GraphQLObjectType ), \
37+ 'Schema subscription must be Object Type but got: {}.' .format (subscription )
38+
3539 self ._query = query
3640 self ._mutation = mutation
41+ self ._subscription = subscription
3742 self ._type_map = self ._build_type_map ()
3843 self ._directives = None
3944
@@ -48,6 +53,9 @@ def get_query_type(self):
4853 def get_mutation_type (self ):
4954 return self ._mutation
5055
56+ def get_subscription_type (self ):
57+ return self ._subscription
58+
5159 def get_type_map (self ):
5260 return self ._type_map
5361
@@ -72,7 +80,8 @@ def get_directive(self, name):
7280
7381 def _build_type_map (self ):
7482 type_map = OrderedDict ()
75- for type in (self .get_query_type (), self .get_mutation_type (), IntrospectionSchema ):
83+ types = (self .get_query_type (), self .get_mutation_type (), self .get_subscription_type (), IntrospectionSchema )
84+ for type in types :
7685 type_map = type_map_reducer (type_map , type )
7786
7887 return type_map
0 commit comments