public static Package parseJson(InputStream source) throws EGraphQLException, IOException, EGraphEngine { JsonObject json = (JsonObject) new com.google.gson.JsonParser().parse(TextFile.streamToString(source)); Parser self = new Parser(); self.reader = new StringReader(json.get("query").getAsString()); self.next(); Package result = new Package(self.parseDocument()); result.setOperationName(json.get("operationName").getAsString()); if (json.has("variables")) { JsonObject vl = json.getAsJsonObject("variables"); for (Entry<String, JsonElement> n : vl.entrySet()) result.getVariables().add(new Argument(n.getKey(), n.getValue())); } return result; }
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 "); } }
public static Package parse(String source) throws IOException, EGraphQLException, EGraphEngine { Parser self = new Parser(); self.reader = new StringReader(source); self.next(); Document doc = self.parseDocument(); return new Package(doc); }
Fragment fragment = graphQL.getDocument().fragment(sel.getFragmentSpread().getName()); if (fragment == null) throw new EGraphQLException("Unable to resolve fragment "+sel.getFragmentSpread().getName());
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 "); } }
public static Package parse(InputStream source) throws IOException, EGraphQLException, EGraphEngine { Parser self = new Parser(); self.reader = new InputStreamReader(source); self.next(); Document doc = self.parseDocument(); return new Package(doc); }
Fragment fragment = graphQL.getDocument().fragment(sel.getFragmentSpread().getName()); if (fragment == null) throw new EGraphQLException("Unable to resolve fragment "+sel.getFragmentSpread().getName());
public static Package parseJson(InputStream source) throws EGraphQLException, IOException, EGraphEngine { JsonObject json = (JsonObject) new com.google.gson.JsonParser().parse(TextFile.streamToString(source)); Parser self = new Parser(); self.reader = new StringReader(json.get("query").getAsString()); self.next(); Package result = new Package(self.parseDocument()); result.setOperationName(json.get("operationName").getAsString()); if (json.has("variables")) { JsonObject vl = json.getAsJsonObject("variables"); for (Entry<String, JsonElement> n : vl.entrySet()) result.getVariables().add(new Argument(n.getKey(), n.getValue())); } return result; }
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, ""); }
public static Package parse(String source) throws IOException, EGraphQLException, EGraphEngine { Parser self = new Parser(); self.reader = new StringReader(source); self.next(); Document doc = self.parseDocument(); return new Package(doc); }
public static Package parse(InputStream source) throws IOException, EGraphQLException, EGraphEngine { Parser self = new Parser(); self.reader = new InputStreamReader(source); self.next(); Document doc = self.parseDocument(); return new Package(doc); }