Skip to content

Commit

Permalink
Apply fix (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock authored Nov 3, 2024
1 parent bb9f6a9 commit f8cc183
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
28 changes: 26 additions & 2 deletions alias/language/parser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,34 @@ const _parse = makeParser(root);
const _parseValue = makeParser(value);
const _parseType = makeParser(type);

export function parse(input) {
export function parse(input, options) {
const result = _parse(input);
if (result == null) throw new GraphQLError('Syntax Error');
return result;
if (options && options.noLocation) return result;

let loc;
return {
...result,
set loc(_loc) {
loc = _loc;
},
get loc() {
if (!loc) {
loc = {
start: 0,
end: input.length,
startToken: undefined,
endToken: undefined,
source: {
body: input,
name: 'graphql-web-lite',
locationOffset: { line: 1, column: 1 },
},
};
}
return loc;
},
};
}

export function parseValue(input) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "graphql-web-lite",
"description": "graphql npm package slimmed down for client-side libraries",
"version": "15.5.1002",
"version": "15.5.1003",
"license": "MIT",
"private": true,
"workspaces": [
Expand Down

0 comments on commit f8cc183

Please sign in to comment.