Skip to content

Commit b176d67

Browse files
author
Daniel Woelfel
committed
location -> locationOffset
1 parent 42e9492 commit b176d67

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/error/syntaxError.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function syntaxError(
2222
description: string
2323
): GraphQLError {
2424
const location = getLocation(source, position);
25-
const line = location.line + source.location.line - 1;
25+
const line = location.line + source.locationOffset.line - 1;
2626
const error = new GraphQLError(
2727
`Syntax Error ${source.name} (${line}:${location.column}) ${description}` +
2828
'\n\n' +
@@ -40,7 +40,7 @@ export function syntaxError(
4040
*/
4141
function highlightSourceAtLocation(source, location) {
4242
const line = location.line;
43-
const lineOffset = source.location.line - 1;
43+
const lineOffset = source.locationOffset.line - 1;
4444
const contextLine = line + lineOffset;
4545
const prevLineNum = (contextLine - 1).toString();
4646
const lineNum = contextLine.toString();

src/language/source.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ type Location = {
1515

1616
/**
1717
* A representation of source input to GraphQL.
18-
* `name` and `location` are optional. They are useful for clients who store
19-
* GraphQL documents in source files; for example, if the GraphQL input starts
20-
* at line 40 in a file named Foo.graphql, it might be useful for name to be
21-
* "Foo.graphql" and location to be `{ line: 40, column: 0 }`.
18+
* `name` and `locationOffset` are optional. They are useful for clients who
19+
* store GraphQL documents in source files; for example, if the GraphQL input
20+
* starts at line 40 in a file named Foo.graphql, it might be useful for name to
21+
* be "Foo.graphql" and location to be `{ line: 40, column: 0 }`.
2222
*/
2323
export class Source {
2424
body: string;
2525
name: string;
26-
location: Location;
26+
locationOffset: Location;
2727

28-
constructor(body: string, name?: string, location?: Location): void {
28+
constructor(body: string, name?: string, locationOffset?: Location): void {
2929
this.body = body;
3030
this.name = name || 'GraphQL request';
31-
this.location = location || { line: 1, column: 0 };
31+
this.locationOffset = locationOffset || { line: 1, column: 0 };
3232
}
3333
}

0 commit comments

Comments
 (0)