public static Package parseFile(String filename) throws FileNotFoundException, IOException, EGraphQLException, EGraphEngine { String src = TextFile.fileToString(filename); return parse(src); }
@GraphQL public String graphql(ServletRequestDetails theRequestDetails, @IdParam IIdType theId, @GraphQLQuery String theQuery) { GraphQLEngine engine = new GraphQLEngine(myWorkerContext); engine.setServices(myStorageServices); try { engine.setGraphQL(Parser.parse(theQuery)); } catch (Exception theE) { throw new InvalidRequestException("Unable to parse GraphQL Expression: " + theE.toString()); } try { if (theId != null) { Resource focus = myStorageServices.lookup(theRequestDetails, theId.getResourceType(), theId.getIdPart()); engine.setFocus(focus); } engine.execute(); StringBuilder outputBuilder = new StringBuilder(); ObjectValue output = engine.getOutput(); output.write(outputBuilder, 0, "\n"); return outputBuilder.toString(); } catch (Exception theE) { throw new InvalidRequestException("Unable to execute GraphQL Expression: " + theE.toString()); } }
public static Package parseFile(String filename) throws FileNotFoundException, IOException, EGraphQLException, EGraphEngine { String src = TextFile.fileToString(filename); return parse(src); }
@GraphQL public String graphql(ServletRequestDetails theRequestDetails, @IdParam IIdType theId, @GraphQLQuery String theQuery) { GraphQLEngine engine = new GraphQLEngine(myWorkerContext); engine.setServices(myStorageServices); try { engine.setGraphQL(Parser.parse(theQuery)); } catch (Exception theE) { throw new InvalidRequestException("Unable to parse GraphQL Expression: " + theE.toString()); } try { if (theId != null) { Resource focus = myStorageServices.lookup(theRequestDetails, theId.getResourceType(), theId.getIdPart()); engine.setFocus(focus); } engine.execute(); StringBuilder outputBuilder = new StringBuilder(); ObjectValue output = engine.getOutput(); output.write(outputBuilder, 0, "\n"); return outputBuilder.toString(); } catch (Exception theE) { throw new InvalidRequestException("Unable to execute GraphQL Expression: " + theE.toString()); } }