-
Notifications
You must be signed in to change notification settings - Fork 51
Parser refuses valid query input if immediately followed by a fragment definition #68
Description
If the query below was passed by stdin, the Parser (v3.0.2) reacted with an error message like ..."/graphql/June2018/#Document".
query {
person(name: "Joe") { ...personFields }
}
fragment personFields on Person { id }
Note the blank line before the fragment definition. I found this while testing a main loop more or less copied from the today example. Therein, the statement
while (std::getline(std::cin, line)) {input.append(line);}
effectively strips newline characters.
When feeding the query via stdin, the query resulted in an error -- but not when the query was passed as a filename to be read via peg::parseFile(argv[1]) directly. Yet the real problem seems to be hidden in the parser. The follwing input (with angle brackets denoting the exact content )
<query{person(name:"Joe"){...personFields}}fragment personFields on Person {id}>
fails with boths variants (stdin, passing file name: premature EOF), whereas inserting a space between "} and "fragment" is sufficient to get the input accepted.
Since the grammar looks fine this behaviour may also be caused by a compiler bug. I used gcc-9.1. gcc-9.2 did not succeed because of some weired problems within a cppgraphqlgen header.