Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pipeline/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@
<version>0.0.2</version>
</dependency>

<!-- GraphQL -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-graphql</artifactId>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ public ResponseEntity<PipelineDTO> updatePipeline(
}
return ResponseEntity.ok(pipelineService.replacePipeline(pipelineId, putRequest));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.autobuild.pipeline.definiton.controller;

import java.io.IOException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.graphql.data.method.annotation.Argument;
import org.springframework.graphql.data.method.annotation.QueryMapping;
import org.springframework.stereotype.Controller;

import com.autobuild.pipeline.definiton.dto.PipelineDTO;
import com.autobuild.pipeline.definiton.exceptions.InvalidIdException;
import com.autobuild.pipeline.definiton.service.PipelineService;

/**
* GraphQL controller for read-only pipeline queries.
*
* @author Suvabrata Chowdhury
*/
@Controller
public class PipelineGraphQLController {

@Autowired
private PipelineService pipelineService;

/**
* Fetch a single pipeline by its ID.
*
* @param pipelineId the pipeline identifier
* @return the matching pipeline
* @throws InvalidIdException if no pipeline exists for the given ID
* @throws IOException if the pipeline script files cannot be read
*/
@QueryMapping
public PipelineDTO getPipelineById(@Argument String pipelineId)
throws InvalidIdException, IOException {
return pipelineService.getPipelineById(pipelineId);
}

/**
* Fetch all pipelines.
*
* @return list of all pipelines
*/
@QueryMapping
public List<PipelineDTO> getAllPipelines() {
return pipelineService.getAllPipelines();
}
}
3 changes: 3 additions & 0 deletions pipeline/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
spring:
application:
name: pipeline
graphql:
graphiql:
enabled: true

logging:
pattern:
Expand Down
18 changes: 18 additions & 0 deletions pipeline/src/main/resources/graphql/pipeline.graphqls
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
type Query {
getPipelineById(pipelineId: ID!): Pipeline
getAllPipelines: [Pipeline!]!
}

type Pipeline {
id: ID
name: String!
stages: [Stage!]!
}

type Stage {
id: ID
name: String!
scriptType: String!
command: String
stageOrder: Int!
}
Loading