@@ -149,39 +149,57 @@ export function execute(
149
149
fieldResolver
150
150
) {
151
151
// Extract arguments from object args if provided.
152
- return arguments . length === 1 ?
153
- executeImpl ( argsOrSchema ) :
154
- executeImpl ( {
155
- schema : argsOrSchema ,
152
+ const args = arguments . length === 1 ? argsOrSchema : undefined ;
153
+ const schema = args ? args . schema : argsOrSchema ;
154
+ return args ?
155
+ executeImpl (
156
+ schema ,
157
+ args . document ,
158
+ args . rootValue ,
159
+ args . contextValue ,
160
+ args . variableValues ,
161
+ args . operationName ,
162
+ args . fieldResolver
163
+ ) :
164
+ executeImpl (
165
+ schema ,
156
166
document ,
157
167
rootValue ,
158
168
contextValue ,
159
169
variableValues ,
160
170
operationName ,
161
171
fieldResolver
162
- } ) ;
172
+ ) ;
163
173
}
164
174
165
- function executeImpl(args) {
175
+ function executeImpl(
176
+ schema,
177
+ document,
178
+ rootValue,
179
+ contextValue,
180
+ variableValues,
181
+ operationName,
182
+ fieldResolver
183
+ ) {
166
184
// If arguments are missing or incorrect, throw an error.
167
185
assertValidExecutionArguments (
168
- args . schema ,
169
- args . document ,
170
- args . variableValues
186
+ schema ,
187
+ document ,
188
+ variableValues
171
189
) ;
172
190
173
191
// If a valid context cannot be created due to incorrect arguments,
174
192
// a "Response" with only errors is returned.
175
193
let context ;
176
194
try {
177
195
context = buildExecutionContext (
178
- args . schema ,
179
- args . document ,
180
- args . rootValue ,
181
- args . contextValue ,
182
- args . variableValues ,
183
- args . operationName ,
184
- args . fieldResolver
196
+ schema ,
197
+ document ,
198
+ rootValue ,
199
+ contextValue ,
200
+ variableValues ,
201
+ operationName ,
202
+ fieldResolver
185
203
) ;
186
204
} catch (error) {
187
205
return Promise . resolve ( { errors : [ error ] } ) ;
@@ -195,7 +213,7 @@ function executeImpl(args) {
195
213
// be executed. An execution which encounters errors will still result in a
196
214
// resolved Promise.
197
215
return Promise.resolve(
198
- executeOperation(context)
216
+ executeOperation(context, context.operation, rootValue )
199
217
).then(data => context . errors . length === 0 ?
200
218
{ data } :
201
219
{ errors : context . errors , data }
@@ -323,9 +341,10 @@ export function buildExecutionContext(
323
341
*/
324
342
function executeOperation (
325
343
exeContext : ExecutionContext ,
344
+ operation : OperationDefinitionNode ,
345
+ rootValue : mixed
326
346
) : ?{ [ key : string ] : mixed } {
327
- const { schema , operation , rootValue } = exeContext;
328
- const type = getOperationRootType(schema, operation);
347
+ const type = getOperationRootType ( exeContext . schema , operation ) ;
329
348
const fields = collectFields (
330
349
exeContext ,
331
350
type ,
0 commit comments