Search in sources :

Example 1 with GraphQLResponse

use of org.hl7.fhir.utilities.graphql.GraphQLResponse in project org.hl7.fhir.core by hapifhir.

the class GraphQLEngine method execute.

@Override
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 GraphQLResponse();
    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, "");
}
Also used : EGraphEngine(org.hl7.fhir.utilities.graphql.EGraphEngine) ExpressionNode(org.hl7.fhir.r4b.model.ExpressionNode) GraphQLResponse(org.hl7.fhir.utilities.graphql.GraphQLResponse) Operation(org.hl7.fhir.utilities.graphql.Operation) EGraphQLException(org.hl7.fhir.utilities.graphql.EGraphQLException)

Example 2 with GraphQLResponse

use of org.hl7.fhir.utilities.graphql.GraphQLResponse in project org.hl7.fhir.core by hapifhir.

the class GraphQLEngine method execute.

@Override
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 GraphQLResponse();
    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, "");
}
Also used : EGraphEngine(org.hl7.fhir.utilities.graphql.EGraphEngine) GraphQLResponse(org.hl7.fhir.utilities.graphql.GraphQLResponse) Operation(org.hl7.fhir.utilities.graphql.Operation) EGraphQLException(org.hl7.fhir.utilities.graphql.EGraphQLException)

Aggregations

EGraphEngine (org.hl7.fhir.utilities.graphql.EGraphEngine)2 EGraphQLException (org.hl7.fhir.utilities.graphql.EGraphQLException)2 GraphQLResponse (org.hl7.fhir.utilities.graphql.GraphQLResponse)2 Operation (org.hl7.fhir.utilities.graphql.Operation)2 ExpressionNode (org.hl7.fhir.r4b.model.ExpressionNode)1