Search in sources :

Example 1 with BuildDiffRequest

use of net.nemerosa.ontrack.extension.api.model.BuildDiffRequest in project ontrack by nemerosa.

the class GitChangeLogBranchGraphQLFieldContributor method gitChangeLogFetcher.

private DataFetcher gitChangeLogFetcher() {
    return fetcher(Branch.class, (DataFetchingEnvironment environment, Branch branch) -> {
        String from = GraphqlUtils.getStringArgument(environment, "from").orElseThrow(() -> new IllegalStateException("From argument is required."));
        String to = GraphqlUtils.getStringArgument(environment, "to").orElseThrow(() -> new IllegalStateException("To argument is required."));
        Build fromBuild = structureService.findBuildByName(branch.getProject().getName(), branch.getName(), from).orElseThrow(() -> new BuildNotFoundException(branch.getProject().getName(), branch.getName(), from));
        Build toBuild = structureService.findBuildByName(branch.getProject().getName(), branch.getName(), to).orElseThrow(() -> new BuildNotFoundException(branch.getProject().getName(), branch.getName(), to));
        return gitService.changeLog(new BuildDiffRequest(fromBuild.getId(), toBuild.getId()));
    });
}
Also used : BuildDiffRequest(net.nemerosa.ontrack.extension.api.model.BuildDiffRequest) BuildNotFoundException(net.nemerosa.ontrack.model.exceptions.BuildNotFoundException) GraphQLString(graphql.Scalars.GraphQLString) DataFetchingEnvironment(graphql.schema.DataFetchingEnvironment)

Aggregations

GraphQLString (graphql.Scalars.GraphQLString)1 DataFetchingEnvironment (graphql.schema.DataFetchingEnvironment)1 BuildDiffRequest (net.nemerosa.ontrack.extension.api.model.BuildDiffRequest)1 BuildNotFoundException (net.nemerosa.ontrack.model.exceptions.BuildNotFoundException)1