private Fragment parseFragment() throws EGraphQLException, IOException { Fragment result = new Fragment(); result.setName(consumeName()); consumeName("on"); result.setTypeCondition(consumeName()); parseFragmentInner(result); return result; }
private Fragment parseInlineFragment() throws EGraphQLException, IOException { Fragment result = new Fragment(); if (hasName("on")) { consumeName("on"); result.setTypeCondition(consumeName()); } parseFragmentInner(result); return result; }
private FragmentSpread parseFragmentSpread() throws EGraphQLException, IOException { FragmentSpread result = new FragmentSpread(); result.setName(consumeName()); while (hasPunctuation("@")) result.getDirectives().add(parseDirective()); return result; }
private Operation parseOperation(String name) throws EGraphQLException, IOException { Operation result = new Operation(); if (name.equals("mutation")) { result.setOperationType(Operation.OperationType.qglotMutation); if (hasName()) result.setName(consumeName()); } else if (name.equals("query")) { result.setOperationType(Operation.OperationType.qglotQuery); if (hasName()) result.setName(consumeName()); } else result.setName(name); parseOperationInner(result); return result; }
private Document parseDocument() throws EGraphQLException, IOException, EGraphEngine { Document doc = new Document(); if (!hasName()) { Operation op = new Operation(); parseOperationInner(op); doc.getOperations().add(op); } else { while (!readerDone || (peek != null)) { String s = consumeName(); if (s.equals("mutation") || (s.equals("query"))) doc.getOperations().add(parseOperation(s)); else if (s.equals("fragment")) doc.getFragments().add(parseFragment()); else throw new EGraphEngine("Not done yet"); // doc.Operations.Add(parseOperation(s))? } } return doc; }
private Variable parseVariable() throws EGraphQLException, IOException { Variable result = new Variable(); consumePunctuation("$"); result.setName(consumeName()); consumePunctuation(":"); result.setTypeName(consumeName()); if (hasPunctuation("=")) { consumePunctuation("="); result.setDefaultValue(parseValue()); } return result; }
private Directive parseDirective() throws EGraphQLException, IOException { Directive result = new Directive(); consumePunctuation("@"); result.setName(consumeName()); if (hasPunctuation("(")) { consumePunctuation("("); do { result.getArguments().add(parseArgument()); } while (!hasPunctuation(")")); consumePunctuation(")"); } return result; }
private Argument parseArgument() throws EGraphQLException, IOException { Argument result = new Argument(); result.setName(consumeName()); consumePunctuation(":"); if (hasPunctuation("[")) { result.setListStatus(ArgumentListStatus.REPEATING); consumePunctuation("["); while (!hasPunctuation("]")) result.getValues().add(parseValue()); consumePunctuation("]"); } else result.getValues().add(parseValue()); return result; }
private Field parseField() throws EGraphQLException, IOException { Field result = new Field(); result.setName(consumeName()); result.setAlias(result.getName()); if (hasPunctuation(":")) { consumePunctuation(":"); result.setName(consumeName()); } if (hasPunctuation("(")) { consumePunctuation("("); while (!hasPunctuation(")")) result.getArguments().add(parseArgument()); consumePunctuation(")"); } while (hasPunctuation("@")) result.getDirectives().add(parseDirective()); if (hasPunctuation("{")) { consumePunctuation("{"); do { result.getSelectionSet().add(parseSelection()); } while (!hasPunctuation("}")); consumePunctuation("}"); } return result; }
private Fragment parseFragment() throws EGraphQLException, IOException { Fragment result = new Fragment(); result.setName(consumeName()); consumeName("on"); result.setTypeCondition(consumeName()); parseFragmentInner(result); return result; }
private Fragment parseInlineFragment() throws EGraphQLException, IOException { Fragment result = new Fragment(); if (hasName("on")) { consumeName("on"); result.setTypeCondition(consumeName()); } parseFragmentInner(result); return result; }
private FragmentSpread parseFragmentSpread() throws EGraphQLException, IOException { FragmentSpread result = new FragmentSpread(); result.setName(consumeName()); while (hasPunctuation("@")) result.getDirectives().add(parseDirective()); return result; }
private Operation parseOperation(String name) throws EGraphQLException, IOException { Operation result = new Operation(); if (name.equals("mutation")) { result.setOperationType(Operation.OperationType.qglotMutation); if (hasName()) result.setName(consumeName()); } else if (name.equals("query")) { result.setOperationType(Operation.OperationType.qglotQuery); if (hasName()) result.setName(consumeName()); } else result.setName(name); parseOperationInner(result); return result; }
private Document parseDocument() throws EGraphQLException, IOException, EGraphEngine { Document doc = new Document(); if (!hasName()) { Operation op = new Operation(); parseOperationInner(op); doc.getOperations().add(op); } else { while (!readerDone || (peek != null)) { String s = consumeName(); if (s.equals("mutation") || (s.equals("query"))) doc.getOperations().add(parseOperation(s)); else if (s.equals("fragment")) doc.getFragments().add(parseFragment()); else throw new EGraphEngine("Not done yet"); // doc.Operations.Add(parseOperation(s))? } } return doc; }
private Variable parseVariable() throws EGraphQLException, IOException { Variable result = new Variable(); consumePunctuation("$"); result.setName(consumeName()); consumePunctuation(":"); result.setTypeName(consumeName()); if (hasPunctuation("=")) { consumePunctuation("="); result.setDefaultValue(parseValue()); } return result; }
private Directive parseDirective() throws EGraphQLException, IOException { Directive result = new Directive(); consumePunctuation("@"); result.setName(consumeName()); if (hasPunctuation("(")) { consumePunctuation("("); do { result.getArguments().add(parseArgument()); } while (!hasPunctuation(")")); consumePunctuation(")"); } return result; }
private Argument parseArgument() throws EGraphQLException, IOException { Argument result = new Argument(); result.setName(consumeName()); consumePunctuation(":"); if (hasPunctuation("[")) { result.setListStatus(ArgumentListStatus.REPEATING); consumePunctuation("["); while (!hasPunctuation("]")) result.getValues().add(parseValue()); consumePunctuation("]"); } else result.getValues().add(parseValue()); return result; }
private Field parseField() throws EGraphQLException, IOException { Field result = new Field(); result.setName(consumeName()); result.setAlias(result.getName()); if (hasPunctuation(":")) { consumePunctuation(":"); result.setName(consumeName()); } if (hasPunctuation("(")) { consumePunctuation("("); while (!hasPunctuation(")")) result.getArguments().add(parseArgument()); consumePunctuation(")"); } while (hasPunctuation("@")) result.getDirectives().add(parseDirective()); if (hasPunctuation("{")) { consumePunctuation("{"); do { result.getSelectionSet().add(parseSelection()); } while (!hasPunctuation("}")); consumePunctuation("}"); } return result; }