Skip to content

Commit 250e6f0

Browse files
author
Daniel Woelfel
committed
Add an invariant to check the locationOffset
1 parent 8da9203 commit 250e6f0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/language/source.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* of patent rights can be found in the PATENTS file in the same directory.
99
*/
1010

11+
import invariant from '../jsutils/invariant';
12+
1113
type Location = {
1214
line: number,
1315
column: number,
@@ -30,5 +32,13 @@ export class Source {
3032
this.body = body;
3133
this.name = name || 'GraphQL request';
3234
this.locationOffset = locationOffset || { line: 1, column: 1 };
35+
invariant(
36+
this.locationOffset.line > 0,
37+
'line in locationOffset is 1-indexed and must be positive'
38+
);
39+
invariant(
40+
this.locationOffset.column > 0,
41+
'column in locationOffset is 1-indexed and must be positive'
42+
);
3343
}
3444
}

0 commit comments

Comments
 (0)