Skip to content

Commit

Permalink
Add GraphQL API to access workflow tags
Browse files Browse the repository at this point in the history
The implementations were already done in the previous commits, but the
GraphQL API was not yet exposed. This commit adds the necessary
implementations to expose the workflow tags through the GraphQL API.

It also fixes a bug in `update_workflow_tag` where it fetched a wrong
tag set.
  • Loading branch information
msk committed Feb 20, 2024
1 parent 57b0e98 commit 87606e0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ Versioning](https://semver.org/spec/v2.0.0.html).

- Add `apply_target_id` field to `Node` struct for reverting node status.
- Add `apply_in_progress` field to `Node` struct for reverting node status.
- Added the following GraphQL API to access workflow tags:
- 'workflowTagList'
- 'insertWorkflowTag'
- 'removeWorkflowTag'
- 'updateWorkflowTag'

### Fixed

Expand Down
2 changes: 2 additions & 0 deletions src/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ pub(super) struct Query(
status::StatusQuery,
tags::EventTagQuery,
tags::NetworkTagQuery,
tags::WorkflowTagQuery,
template::TemplateQuery,
tor_exit_node::TorExitNodeQuery,
tidb::TidbQuery,
Expand Down Expand Up @@ -216,6 +217,7 @@ pub(super) struct Mutation(
status::StatusMutation,
tags::EventTagMutation,
tags::NetworkTagMutation,
tags::WorkflowTagMutation,
template::TemplateMutation,
tor_exit_node::TorExitNodeMutation,
tidb::TidbMutation,
Expand Down
2 changes: 2 additions & 0 deletions src/graphql/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ pub(super) use event_tag::EventTagMutation;
pub(super) use event_tag::EventTagQuery;
pub(super) use network_tag::NetworkTagMutation;
pub(super) use network_tag::NetworkTagQuery;
pub(super) use workflow_tag::WorkflowTagMutation;
pub(super) use workflow_tag::WorkflowTagQuery;

#[derive(SimpleObject)]
#[graphql(complex)]
Expand Down
6 changes: 3 additions & 3 deletions src/graphql/tags/workflow_tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ impl WorkflowTagQuery {
}

#[derive(Default)]
pub(in crate::graphql) struct EventTagMutation;
pub(in crate::graphql) struct WorkflowTagMutation;

#[Object]
impl EventTagMutation {
impl WorkflowTagMutation {
/// Inserts a new workflow tag, returning the ID of the new tag.
async fn insert_workflow_tag(&self, ctx: &Context<'_>, name: String) -> Result<ID> {
let store = crate::graphql::get_store(ctx).await?;
Expand Down Expand Up @@ -57,7 +57,7 @@ impl EventTagMutation {
new: String,
) -> Result<bool> {
let store = crate::graphql::get_store(ctx).await?;
let set = store.event_tag_set();
let set = store.workflow_tag_set();
Ok(set.update(id.0.parse()?, old.as_bytes(), new.as_bytes())?)
}
}

0 comments on commit 87606e0

Please sign in to comment.