Source:
<code>public Document parseDocument(String input, String sourceName) { <START> GraphqlLexer lexer = new GraphqlLexer(CharStreams.fromString(input, Optional.ofNullable(sourceName).orElse(IntStream.UNKNOWN_SOURCE_NAME))); <END> CommonTokenStream tokens = new CommonTokenStream(lexer); GraphqlParser parser = new GraphqlParser(tokens); parser.removeErrorListeners(); parser.getInterpreter().setPredictionMode(PredictionMode.SLL); parser.setErrorHandler(new BailErrorStrategy()); GraphqlParser.DocumentContext document = parser.document(); GraphqlAntlrToLanguage antlrToLanguage = new GraphqlAntlrToLanguage(tokens); antlrToLanguage.visitDocument(document); Token stop = document.getStop(); List<Token> allTokens = tokens.getTokens(); if (stop != null && allTokens != null && !allTokens.isEmpty()) { Token last = allTokens.get(allTokens.size() - 1); boolean notEOF = last.getType() != Token.EOF; boolean lastGreaterThanDocument = last.getTokenIndex() > stop.getTokenIndex(); boolean sameChannel = last.getChannel() == stop.getChannel(); if (notEOF && lastGreaterThanDocument && sameChannel) { throw new ParseCancellationException("There are more tokens in the query that have not been consumed"); } } return antlrToLanguage.getResult(); }</code><technical_language>Yeah point is parser level SourceLocation object. SourceLocation is in error objects. Today is sourceName attribute. PR adds one. JSON today errors : { message : "x y z", locations : [ { line : 10, column : 9 } ], } change a bad client query (as opposed SDL) send errors : { message : "x y z", locations : [ { sourceName : "<unknown>", line : 10, column : 9 } ], } client source - query sent. default NULL IF source name is magic constant String sourceName = startToken.getTokenSource().getSourceName(); if (IntStream.UNKNOWN_SOURCE_NAME.equals(sourceName)) { sourceName = null; } return new SourceLocation(startToken.getLine(), startToken.getCharPositionInLine() + 1, sourceName);</technical_language>

Target:
public Document parseDocument(String input, String sourceName) { CharStream charStream; if(sourceName == null) { charStream = CharStreams.fromString(input); } else{ charStream = CharStreams.fromString(input, sourceName); } GraphqlLexer lexer = new GraphqlLexer(charStream); CommonTokenStream tokens = new CommonTokenStream(lexer); GraphqlParser parser = new GraphqlParser(tokens); parser.removeErrorListeners(); parser.getInterpreter().setPredictionMode(PredictionMode.SLL); parser.setErrorHandler(new BailErrorStrategy()); GraphqlParser.DocumentContext document = parser.document(); GraphqlAntlrToLanguage antlrToLanguage = new GraphqlAntlrToLanguage(tokens); antlrToLanguage.visitDocument(document); Token stop = document.getStop(); List<Token> allTokens = tokens.getTokens(); if (stop != null && allTokens != null && !allTokens.isEmpty()) { Token last = allTokens.get(allTokens.size() - 1); boolean notEOF = last.getType() != Token.EOF; boolean lastGreaterThanDocument = last.getTokenIndex() > stop.getTokenIndex(); boolean sameChannel = last.getChannel() == stop.getChannel(); if (notEOF && lastGreaterThanDocument && sameChannel) { throw new ParseCancellationException("There are more tokens in the query that have not been consumed"); } } return antlrToLanguage.getResult(); }