forked from railwayapp/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkflow.go
More file actions
33 lines (28 loc) · 759 Bytes
/
Copy pathworkflow.go
File metadata and controls
33 lines (28 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package gateway
import (
context "context"
gql "github.com/machinebox/graphql"
"github.com/railwayapp/cli/entity"
"github.com/railwayapp/cli/errors"
)
func (g *Gateway) GetWorkflowStatus(ctx context.Context, workflowID string) (entity.WorkflowStatus, error) {
gqlReq := gql.NewRequest(`
query($workflowId: String!) {
getWorkflowStatus(workflowId: $workflowId) {
status
}
}
`)
err := g.authorize(ctx, gqlReq.Header)
if err != nil {
return "", err
}
gqlReq.Var("workflowId", workflowID)
var resp struct {
WorkflowStatus *entity.WorkflowStatusResponse `json:"getWorkflowStatus"`
}
if err := g.gqlClient.Run(ctx, gqlReq, &resp); err != nil {
return "", errors.ProjectCreateFailed
}
return resp.WorkflowStatus.Status, nil
}