All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.graphql.GraphqlSchemaModule.template Maven / Gradle / Ivy

The newest version!
package @[email protected];

import com.google.api.graphql.rejoiner.GrpcSchemaModule;
import com.google.api.graphql.rejoiner.Mutation;
import com.google.api.graphql.rejoiner.Query;
import com.google.api.graphql.rejoiner.SchemaModule;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.SettableFuture;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.Inject;
import graphql.schema.DataFetchingEnvironment;
import graphql.schema.GraphQLFieldDefinition;

import farm.nurture.infra.util.StringUtils;
import java.util.List;


import @[email protected].*;

/**
 * A Laminar GraphQL {@link SchemaModule} backed by a gRPC service.
 * https://code.nurture.farm/platform/laminargrpc/blob/master/src/main/proto/laminar.proto
 */
public class GraphqlSchemaModule extends GrpcSchemaModule {

    private static Status getErrorStatus ( String msg) {
        if ( null == msg) msg = "Security error.";
        return Status.newBuilder().setStatus(StatusCode.REQUEST_DENIED).
                addErrorMessages(msg).build();
    }

    @Inject
    @microservice_name@Grpc.@microservice_name@FutureStub futureClient;

    @Override
    protected void configureSchema() {

        /**
        //Select queries
        ImmutableList queryList =
                serviceToFields(@microservice_name@Grpc.@[email protected],
                        ImmutableList.of(@queryList@));
        addQueryList(queryList);

        //IUD queries
        ImmutableList mutationList =
                serviceToFields(@microservice_name@Grpc.@[email protected],
                        ImmutableList.of(@mutationList@));
        addMutationList(mutationList);
        */
    }

    static String errMsg = "Security check failure";

    @overrideList@


    private OAuthValidator.VerifyInput getVerifyInput(DataFetchingEnvironment environment, RequestHeaders reqHeaders) {
        OAuthValidator.VerifyInput authAndAppToken = environment.getContext();
        if ( null == authAndAppToken.authToken) authAndAppToken.authToken = reqHeaders.getAuthToken();
        if ( null == authAndAppToken.appToken)  authAndAppToken.appToken = reqHeaders.getAppToken();
        return authAndAppToken;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy