diff --git a/alias/language/parser.mjs b/alias/language/parser.mjs index bb07ff3..f4d288b 100644 --- a/alias/language/parser.mjs +++ b/alias/language/parser.mjs @@ -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) { diff --git a/package.json b/package.json index ebd4211..3adcf24 100644 --- a/package.json +++ b/package.json @@ -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": [