private void parseOperationInner(Operation op) throws EGraphQLException, IOException { if (hasPunctuation("(")) { consumePunctuation("("); do op.getVariables().add(parseVariable()); while (!hasPunctuation(")")); consumePunctuation(")"); } while (hasPunctuation("@")) op.getDirectives().add(parseDirective()); if (hasPunctuation("{")) { consumePunctuation("{"); do op.getSelectionSet().add(parseSelection()); while (!hasPunctuation("}")); consumePunctuation("}"); } }
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; }
public Operation operation(String name) { for (Operation o : operations) if (o.getName().equals(name)) return o; return null; } }
public void execute() throws EGraphEngine, EGraphQLException, FHIRException { if (graphQL == null) throw new EGraphEngine("Unable to process graphql - graphql document missing"); fpe = new FHIRPathEngine(this.context); magicExpression = new ExpressionNode(0); output = new ObjectValue(); Operation op = null; // todo: initial conditions if (!Utilities.noString(graphQL.getOperationName())) { op = graphQL.getDocument().operation(graphQL.getOperationName()); if (op == null) throw new EGraphEngine("Unable to find operation \""+graphQL.getOperationName()+"\""); } else if ((graphQL.getDocument().getOperations().size() == 1)) op = graphQL.getDocument().getOperations().get(0); else throw new EGraphQLException("No operation name provided, so expected to find a single operation"); if (op.getOperationType() == OperationType.qglotMutation) throw new EGraphQLException("Mutation operations are not supported (yet)"); checkNoDirectives(op.getDirectives()); processVariables(op); if (focus == null) processSearch(output, op.getSelectionSet(), false, ""); else processObject(focus, focus, output, op.getSelectionSet(), false, ""); }
private void processVariables(Operation op) throws EGraphQLException { for (Variable varRef : op.getVariables()) { Argument varDef = null; for (Argument v : graphQL.getVariables()) if (v.getName().equals(varRef.getName())) varDef = v; if (varDef != null) workingVariables.put(varRef.getName(), varDef); // todo: check type? else if (varRef.getDefaultValue() != null) workingVariables.put(varRef.getName(), new Argument(varRef.getName(), varRef.getDefaultValue())); else throw new EGraphQLException("No value found for variable "); } }
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; }
public void execute() throws EGraphEngine, EGraphQLException, FHIRException { if (graphQL == null) throw new EGraphEngine("Unable to process graphql - graphql document missing"); fpe = new FHIRPathEngine(this.context); magicExpression = new ExpressionNode(0); output = new ObjectValue(); Operation op = null; // todo: initial conditions if (!Utilities.noString(graphQL.getOperationName())) { op = graphQL.getDocument().operation(graphQL.getOperationName()); if (op == null) throw new EGraphEngine("Unable to find operation \""+graphQL.getOperationName()+"\""); } else if ((graphQL.getDocument().getOperations().size() == 1)) op = graphQL.getDocument().getOperations().get(0); else throw new EGraphQLException("No operation name provided, so expected to find a single operation"); if (op.getOperationType() == OperationType.qglotMutation) throw new EGraphQLException("Mutation operations are not supported (yet)"); checkNoDirectives(op.getDirectives()); processVariables(op); if (focus == null) processSearch(output, op.getSelectionSet(), false, ""); else processObject(focus, focus, output, op.getSelectionSet(), false, ""); }
private void processVariables(Operation op) throws EGraphQLException { for (Variable varRef : op.getVariables()) { Argument varDef = null; for (Argument v : graphQL.getVariables()) if (v.getName().equals(varRef.getName())) varDef = v; if (varDef != null) workingVariables.put(varRef.getName(), varDef); // todo: check type? else if (varRef.getDefaultValue() != null) workingVariables.put(varRef.getName(), new Argument(varRef.getName(), varRef.getDefaultValue())); else throw new EGraphQLException("No value found for variable "); } }
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 void parseOperationInner(Operation op) throws EGraphQLException, IOException { if (hasPunctuation("(")) { consumePunctuation("("); do op.getVariables().add(parseVariable()); while (!hasPunctuation(")")); consumePunctuation(")"); } while (hasPunctuation("@")) op.getDirectives().add(parseDirective()); if (hasPunctuation("{")) { consumePunctuation("{"); do op.getSelectionSet().add(parseSelection()); while (!hasPunctuation("}")); consumePunctuation("}"); } }
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; }
public Operation operation(String name) { for (Operation o : operations) if (o.getName().equals(name)) return o; return null; } }