Skip to content

Commit 50768f1

Browse files
committed
Sane executor arguments.
This matches the order of arguments of the main graphql function to the execute function. It also renames some variables to better match how we describe them elsewhere.
1 parent 0afeed9 commit 50768f1

10 files changed

+144
-138
lines changed

src/executor/__tests__/directives.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var data = {
3434
};
3535

3636
async function executeTestQuery(doc) {
37-
return await execute(schema, data, parse(doc));
37+
return await execute(schema, parse(doc), data);
3838
}
3939

4040
describe('Execute: handles directives', () => {

src/executor/__tests__/executor.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ describe('Execute: Handles basic execution tasks', () => {
136136
});
137137

138138
expect(
139-
await execute(schema, data, ast, 'Example', { size: 100 })
139+
await execute(schema, ast, data, { size: 100 }, 'Example')
140140
).to.deep.equal(expected);
141141
});
142142

@@ -167,7 +167,7 @@ describe('Execute: Handles basic execution tasks', () => {
167167
var schema = new GraphQLSchema({ query: Type });
168168

169169
expect(
170-
await execute(schema, null, ast)
170+
await execute(schema, ast)
171171
).to.deep.equal({
172172
data: {
173173
a: 'Apple',
@@ -205,7 +205,7 @@ describe('Execute: Handles basic execution tasks', () => {
205205
})
206206
});
207207

208-
await execute(schema, data, parse(doc), 'Example', {});
208+
await execute(schema, parse(doc), data);
209209

210210
expect(resolvedContext.contextThing).to.equal('thing');
211211
});
@@ -237,7 +237,7 @@ describe('Execute: Handles basic execution tasks', () => {
237237
})
238238
});
239239

240-
await execute(schema, null, parse(doc), 'Example', {});
240+
await execute(schema, parse(doc));
241241

242242
expect(resolvedArgs.numArg).to.equal(123);
243243
expect(resolvedArgs.stringArg).to.equal('foo');
@@ -296,7 +296,7 @@ describe('Execute: Handles basic execution tasks', () => {
296296
}
297297
};
298298

299-
let docAst = parse(doc);
299+
let ast = parse(doc);
300300
var schema = new GraphQLSchema({
301301
query: new GraphQLObjectType({
302302
name: 'Type',
@@ -314,7 +314,7 @@ describe('Execute: Handles basic execution tasks', () => {
314314
})
315315
});
316316

317-
var result = await execute(schema, data, docAst);
317+
var result = await execute(schema, ast, data);
318318

319319
expect(result.data).to.deep.equal({
320320
sync: 'sync',
@@ -359,7 +359,7 @@ describe('Execute: Handles basic execution tasks', () => {
359359
})
360360
});
361361

362-
var result = await execute(schema, data, ast);
362+
var result = await execute(schema, ast, data);
363363

364364
expect(result).to.deep.equal({data: {a: 'b'}});
365365
});
@@ -377,7 +377,7 @@ describe('Execute: Handles basic execution tasks', () => {
377377
})
378378
});
379379

380-
var result = await execute(schema, data, ast);
380+
var result = await execute(schema, ast, data);
381381

382382
expect(result).to.deep.equal({data: {a: 'b'}});
383383
});
@@ -395,7 +395,7 @@ describe('Execute: Handles basic execution tasks', () => {
395395
})
396396
});
397397

398-
expect(() => execute(schema, data, ast)).to.throw(
398+
expect(() => execute(schema, ast, data)).to.throw(
399399
'Must provide operation name if query contains multiple operations.'
400400
);
401401
});
@@ -419,7 +419,7 @@ describe('Execute: Handles basic execution tasks', () => {
419419
})
420420
});
421421

422-
var queryResult = await execute(schema, data, ast, 'Q');
422+
var queryResult = await execute(schema, ast, data, {}, 'Q');
423423

424424
expect(queryResult).to.deep.equal({data: {a: 'b'}});
425425
});
@@ -443,7 +443,7 @@ describe('Execute: Handles basic execution tasks', () => {
443443
})
444444
});
445445

446-
var mutationResult = await execute(schema, data, ast, 'M');
446+
var mutationResult = await execute(schema, ast, data, {}, 'M');
447447

448448
expect(mutationResult).to.deep.equal({data: {c: 'd'}});
449449
});
@@ -475,7 +475,7 @@ describe('Execute: Handles basic execution tasks', () => {
475475
},
476476
};
477477

478-
var docAst = parse(doc);
478+
var ast = parse(doc);
479479
var schema = new GraphQLSchema({
480480
query: new GraphQLObjectType({
481481
name: 'Type',
@@ -489,7 +489,7 @@ describe('Execute: Handles basic execution tasks', () => {
489489
})
490490
});
491491

492-
var result = await execute(schema, data, docAst);
492+
var result = await execute(schema, ast, data);
493493

494494
expect(result).to.deep.equal({
495495
data: {
@@ -528,7 +528,7 @@ describe('Execute: Handles basic execution tasks', () => {
528528
}),
529529
});
530530

531-
var queryResult = await execute(schema, data, ast, 'Q');
531+
var queryResult = await execute(schema, ast, data, {}, 'Q');
532532

533533
expect(queryResult).to.deep.equal({data: {a: 'b'}});
534534
});
@@ -553,7 +553,7 @@ describe('Execute: Handles basic execution tasks', () => {
553553
}),
554554
});
555555

556-
var mutationResult = await execute(schema, null, ast);
556+
var mutationResult = await execute(schema, ast);
557557

558558
expect(mutationResult).to.deep.equal({
559559
data: {

src/executor/__tests__/executor_schema.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ describe('Execute: Handles execution with a complex schema', () => {
156156
// Note: this is intentionally not validating to ensure appropriate
157157
// behavior occurs when executing an invalid query.
158158
return expect(
159-
await execute(BlogSchema, null, parse(request))
159+
await execute(BlogSchema, parse(request))
160160
).to.deep.equal({
161161
data: {
162162
feed: [

src/executor/__tests__/lists.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function check(testType, testData, expected) {
5050

5151
var ast = parse('{ nest { test } }');
5252

53-
var response = await execute(schema, data, ast);
53+
var response = await execute(schema, ast, data);
5454
// Formatting errors for ease of test writing.
5555
var result = response.errors;
5656
if (response.errors) {

src/executor/__tests__/mutations.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ describe('Execute: Handles mutation execution ordering', () => {
129129
theNumber
130130
}
131131
}`;
132-
var ast = parse(doc);
133-
var mutationResult = await execute(schema, new Root(6), ast, 'M');
132+
133+
var mutationResult = await execute(schema, parse(doc), new Root(6));
134+
134135
return expect(mutationResult).to.deep.equal({
135136
data: {
136137
first: {
@@ -152,7 +153,7 @@ describe('Execute: Handles mutation execution ordering', () => {
152153
});
153154
});
154155

155-
it('evaluates mutations correctly in the presense of a failed mutation', () => {
156+
it('evaluates mutations correctly in the presense of a failed mutation', async () => {
156157
var doc = `mutation M {
157158
first: immediatelyChangeTheNumber(newNumber: 1) {
158159
theNumber
@@ -173,33 +174,32 @@ describe('Execute: Handles mutation execution ordering', () => {
173174
theNumber
174175
}
175176
}`;
176-
var ast = parse(doc);
177177

178-
return execute(schema, new Root(6), ast, 'M').then(result => {
179-
expect(result.data).to.deep.equal({
180-
first: {
181-
theNumber: 1
182-
},
183-
second: {
184-
theNumber: 2
185-
},
186-
third: null,
187-
fourth: {
188-
theNumber: 4
189-
},
190-
fifth: {
191-
theNumber: 5
192-
},
193-
sixth: null,
194-
});
178+
var result = await execute(schema, parse(doc), new Root(6));
195179

196-
expect(result.errors).to.have.length(2);
197-
expect(result.errors).to.containSubset([
198-
{ message: 'Cannot change the number',
199-
locations: [ { line: 8, column: 7 } ] },
200-
{ message: 'Cannot change the number',
201-
locations: [ { line: 17, column: 7 } ] }
202-
]);
180+
expect(result.data).to.deep.equal({
181+
first: {
182+
theNumber: 1
183+
},
184+
second: {
185+
theNumber: 2
186+
},
187+
third: null,
188+
fourth: {
189+
theNumber: 4
190+
},
191+
fifth: {
192+
theNumber: 5
193+
},
194+
sixth: null,
203195
});
196+
197+
expect(result.errors).to.have.length(2);
198+
expect(result.errors).to.containSubset([
199+
{ message: 'Cannot change the number',
200+
locations: [ { line: 8, column: 7 } ] },
201+
{ message: 'Cannot change the number',
202+
locations: [ { line: 17, column: 7 } ] }
203+
]);
204204
});
205205
});

0 commit comments

Comments
 (0)