parseSelectionSet method

SelectionSetContext? parseSelectionSet()

Implementation

SelectionSetContext? parseSelectionSet() {
  if (next(TokenType.LBRACE) && current != null) {
    var LBRACE = current!;
    var selections = <SelectionContext>[];
    var selection = parseSelection();

    while (selection != null) {
      selections.add(selection);
      eatCommas();
      selection = parseSelection();
    }

    eatCommas();
    if (next(TokenType.RBRACE)) {
      return SelectionSetContext(LBRACE, current)
        ..selections.addAll(selections);
    } else {
      errors.add(SyntaxError('Missing "}" after selection set.',
          selections.isEmpty ? LBRACE.span : selections.last.span));
      return null;
    }
  } else {
    return null;
  }
}