Skip to content

Commit e81cf39

Browse files
committed
[Validation] Report var def before var usage
1 parent 1d14db7 commit e81cf39

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/validation/__tests__/VariablesInAllowedPosition.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ describe('Validate: Variables are in allowed positions', () => {
184184
}
185185
`, [
186186
{ message: badVarPosMessage('intArg', 'Int', 'Int!'),
187-
locations: [ { line: 4, column: 45 }, { line: 2, column: 19 } ] },
187+
locations: [ { line: 2, column: 19 }, { line: 4, column: 45 } ] },
188188
]);
189189
});
190190

@@ -201,7 +201,7 @@ describe('Validate: Variables are in allowed positions', () => {
201201
}
202202
`, [
203203
{ message: badVarPosMessage('intArg', 'Int', 'Int!'),
204-
locations: [ { line: 3, column: 43 }, { line: 6, column: 19 } ] }
204+
locations: [ { line: 6, column: 19 }, { line: 3, column: 43 } ] }
205205
]);
206206
});
207207

@@ -222,7 +222,7 @@ describe('Validate: Variables are in allowed positions', () => {
222222
}
223223
`, [
224224
{ message: badVarPosMessage('intArg', 'Int', 'Int!'),
225-
locations: [ { line: 7, column: 43 }, { line: 10, column: 19 } ] }
225+
locations: [ { line: 10, column: 19 }, { line: 7, column: 43 } ] }
226226
]);
227227
});
228228

@@ -235,7 +235,7 @@ describe('Validate: Variables are in allowed positions', () => {
235235
}
236236
`, [
237237
{ message: badVarPosMessage('stringVar', 'String', 'Boolean'),
238-
locations: [ { line: 4, column: 39 }, { line: 2, column: 19 } ] }
238+
locations: [ { line: 2, column: 19 }, { line: 4, column: 39 } ] }
239239
]);
240240
});
241241

@@ -248,7 +248,7 @@ describe('Validate: Variables are in allowed positions', () => {
248248
}
249249
`, [
250250
{ message: badVarPosMessage('stringVar', 'String', '[String]'),
251-
locations: [ { line: 4, column: 45 }, { line: 2, column: 19 } ] }
251+
locations: [ { line: 2, column: 19 }, { line: 4, column: 45 } ] }
252252
]);
253253
});
254254

@@ -259,7 +259,7 @@ describe('Validate: Variables are in allowed positions', () => {
259259
}
260260
`, [
261261
{ message: badVarPosMessage('boolVar', 'Boolean', 'Boolean!'),
262-
locations: [ { line: 3, column: 26 }, { line: 2, column: 19 } ] }
262+
locations: [ { line: 2, column: 19 }, { line: 3, column: 26 } ] }
263263
]);
264264
});
265265

@@ -270,7 +270,7 @@ describe('Validate: Variables are in allowed positions', () => {
270270
}
271271
`, [
272272
{ message: badVarPosMessage('stringVar', 'String', 'Boolean!'),
273-
locations: [ { line: 3, column: 26 }, { line: 2, column: 19 } ] }
273+
locations: [ { line: 2, column: 19 }, { line: 3, column: 26 } ] }
274274
]);
275275
});
276276

src/validation/rules/VariablesInAllowedPosition.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function VariablesInAllowedPosition(context: ValidationContext): any {
4646
!varTypeAllowedForType(effectiveType(varType, varDef), type)) {
4747
context.reportError(new GraphQLError(
4848
badVarPosMessage(varName, varType, type),
49-
[ node, varDef ]
49+
[ varDef, node ]
5050
));
5151
}
5252
}

0 commit comments

Comments
 (0)