/** * Write the output using the system default line separator (as defined in {@link System#lineSeparator} * @param b The StringBuilder to populate * @param indent The indent level, or <code>-1</code> for no indent */ public void write(StringBuilder b, int indent) throws EGraphQLException, EGraphEngine { write(b, indent, System.lineSeparator()); }
@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()); } }
/** * Write the output using the system default line separator (as defined in {@link System#lineSeparator} * @param b The StringBuilder to populate * @param indent The indent level, or <code>-1</code> for no indent */ public void write(StringBuilder b, int indent) throws EGraphQLException, EGraphEngine { write(b, indent, System.lineSeparator()); }
@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()); } }