11from future import standard_library
22standard_library .install_aliases ()
3- from builtins import filter
43from builtins import object
54from types import FunctionType
65import pickle
@@ -61,8 +60,10 @@ def wait_and_get_message(self):
6160 gevent .sleep (.001 )
6261
6362 def handle_message (self , message ):
63+ if isinstance (message ['channel' ], bytes ):
64+ channel = message ['channel' ].decode ()
6465 for sub_id , trigger_map in self .subscriptions .items ():
65- if trigger_map [0 ] == message [ ' channel' ] :
66+ if trigger_map [0 ] == channel :
6667 trigger_map [1 ](pickle .loads (message ['data' ]))
6768
6869
@@ -141,14 +142,14 @@ def subscribe(self, query, operation_name, callback, variables, context,
141142 'channel_options' , {})
142143 filter = trigger_map [trigger_name ].get ('filter' ,
143144 lambda arg1 , arg2 : True )
144- # TODO: Think about this some more...the Apollo library
145- # let's all messages through by default, even if
146- # the users incorrectly uses the setup_funcs (does not
147- # use 'filter' or 'channel_options' keys); I think it
148- # would be better to raise an exception here
149145 except AttributeError :
150146 channel_options = {}
151147
148+ # TODO: Think about this some more...the Apollo library
149+ # let's all messages through by default, even if
150+ # the users incorrectly uses the setup_funcs (does not
151+ # use 'filter' or 'channel_options' keys); I think it
152+ # would be better to raise an exception here
152153 def filter (arg1 , arg2 ):
153154 return True
154155
@@ -160,7 +161,7 @@ def context_promise_handler(result):
160161 return context
161162
162163 def filter_func_promise_handler (context ):
163- return Promise .all ([context , list ( filter (root_value , context ) )])
164+ return Promise .all ([context , filter (root_value , context )])
164165
165166 def context_do_execute_handler (result ):
166167 context , do_execute = result
0 commit comments