22import  functools 
33import  logging 
44import  sys 
5+ import  warnings 
56from  rx  import  Observable 
67
78from  six  import  string_types 
@@ -28,9 +29,31 @@ def subscribe(*args, **kwargs):
2829 return  execute (* args , allow_subscriptions = allow_subscriptions , ** kwargs )
2930
3031
31- def  execute (schema , document_ast , root_value = None , context_value = None ,
32-  variable_values = None , operation_name = None , executor = None ,
33-  return_promise = False , middleware = None , allow_subscriptions = False ):
32+ def  execute (schema , document_ast , root = None , context = None ,
33+  variables = None , operation_name = None , executor = None ,
34+  return_promise = False , middleware = None , allow_subscriptions = False , ** options ):
35+ 
36+  if  root  is  None  and  'root_value'  in  options :
37+  warnings .warn (
38+  'root_value has been deprecated. Please use root=... instead.' ,
39+  category = DeprecationWarning ,
40+  stacklevel = 2 
41+  )
42+  root  =  options ['root_value' ]
43+  if  context  is  None  and  'context_value'  in  options :
44+  warnings .warn (
45+  'context_value has been deprecated. Please use context=... instead.' ,
46+  category = DeprecationWarning ,
47+  stacklevel = 2 
48+  )
49+  context  =  options ['context_value' ]
50+  if  variables  is  None  and  'variable_values'  in  options :
51+  warnings .warn (
52+  'variable_values has been deprecated. Please use values=... instead.' ,
53+  category = DeprecationWarning ,
54+  stacklevel = 2 
55+  )
56+  variables  =  options ['variable_values' ]
3457 assert  schema , 'Must provide schema' 
3558 assert  isinstance (schema , GraphQLSchema ), (
3659 'Schema must be an instance of GraphQLSchema. Also ensure that there are '  + 
@@ -49,38 +72,38 @@ def execute(schema, document_ast, root_value=None, context_value=None,
4972 if  executor  is  None :
5073 executor  =  SyncExecutor ()
5174
52-  context  =  ExecutionContext (
75+  exe_context  =  ExecutionContext (
5376 schema ,
5477 document_ast ,
55-  root_value ,
56-  context_value ,
57-  variable_values ,
78+  root ,
79+  context ,
80+  variables   or  {} ,
5881 operation_name ,
5982 executor ,
6083 middleware ,
6184 allow_subscriptions 
6285 )
6386
6487 def  executor (v ):
65-  return  execute_operation (context ,  context .operation , root_value )
88+  return  execute_operation (exe_context ,  exe_context .operation , root )
6689
6790 def  on_rejected (error ):
68-  context .errors .append (error )
91+  exe_context .errors .append (error )
6992 return  None 
7093
7194 def  on_resolve (data ):
7295 if  isinstance (data , Observable ):
7396 return  data 
7497
75-  if  not  context .errors :
98+  if  not  exe_context .errors :
7699 return  ExecutionResult (data = data )
77100
78-  return  ExecutionResult (data = data , errors = context .errors )
101+  return  ExecutionResult (data = data , errors = exe_context .errors )
79102
80103 promise  =  Promise .resolve (None ).then (executor ).catch (on_rejected ).then (on_resolve )
81104
82105 if  not  return_promise :
83-  context .executor .wait_until_finished ()
106+  exe_context .executor .wait_until_finished ()
84107 return  promise .get ()
85108
86109 return  promise 
0 commit comments