andreas / ocaml-graphql-server

GraphQL servers in OCaml
MIT License
624 stars 60 forks source link

Fix parsing arguments with default values in positions other than last #135

Closed anmonteiro closed 5 years ago

anmonteiro commented 5 years ago

cc @sgrove who reported this to me.

andreas commented 5 years ago

Thanks for pointing this out and coming up with a test case!

I've tried to follow the rule that "grammar elements" should consume ignored characters before it, but not after. This allows elements to compose nicely without backtracking on ignored characters. That's also why lift3' does not consume ignored characters after the last element.

As such, I'd prefer updating variable_definitions to use sep_by ignored variable_definition rather than have variable_definition consume ignored characters after it.

With that being said, I'm about to merge #132, which I've confirmed fixes this bug also.