angel-dart-archive / graphql

moved to angel-dart/angel/packages/graphql

Home Page:https://github.com/angel-dart/angel/tree/master/packages/graphql

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

parser does not parse queries with array inputs

dustin-graham opened this issue · comments

*This issue was automatically moved to: angel-dart/angel#206.

I'll be sure to get to this later today.

@thosakwe now that's response time! wow. thanks.

looking closer it seems probably the place to fix it is in parser.dart:

 ValueOrVariableContext parseValueOrVariable() {
    var value = parseValue();
    if (value != null)
      return new ValueOrVariableContext(value, null);
    else {
      var variable = parseVariable();
      if (variable != null)
        return new ValueOrVariableContext(null, variable);
      else
        return null;
    }
  }

The issue seems to be that something like the array literal:
[$variable]
is both a value and a variable together.

parseValue() will successfully detect values that appear inside an array, but expects value literals all the way down.

parseVariable() does not expect any literal values and so an array literal enclosing a variable is not going to get seen.

I haven't pinpointed why this does not produce an error though.

Sorry, forgot to update you. In the coming graphql_parser release, variable has been folded in as a subclass of value. In the 2016 spec, they were separate, and originally the parser was written for the 2016 spec (project was started in 2016). But this coming release should fulfill the full 2018 spec, as it'll also parse the ad-hoc type IDL (which previously wasn't parsed, as the packages were intended for servers).