-
Notifications
You must be signed in to change notification settings - Fork 88
Add alert type GraphQL query #2811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
GregorShear
wants to merge
14
commits into
master
Choose a base branch
from
greg/alert-type-query
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cf01c9f
Add alert type query with name and description
GregorShear 1badf93
Merge branch 'master' into greg/alert-type-query
kiahna-tucker 7105cd7
Add is_default and is_system_alert properties to AlertTypeInfo
kiahna-tucker e022347
Correct syntax error in alerts.rs
kiahna-tucker b090ff3
Correct syntax error in alerts.rs
kiahna-tucker 76e2a2d
Preserve system alert types when creating and updating a subscription
kiahna-tucker 27c86d9
Correct formatting of alert_subscriptions.rs
kiahna-tucker d247427
Correct formatting of alert_subscriptions.rs
kiahna-tucker f3b2f48
Correct search and replace typo
kiahna-tucker 03e8466
Adjust resolved_alert_type initialization logic
kiahna-tucker 6d2b81f
Correct formatting of alert_subscriptions.rs
kiahna-tucker 2b473ca
Adjust resolved_alert_type initialization logic
kiahna-tucker c973a00
Adjust resolved_alert_type initialization logic
kiahna-tucker ffddbec
Comment out broken logic
kiahna-tucker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # control-plane-api | ||
|
|
||
| ## Development | ||
|
|
||
| > **NOTE:** All commands below should be run from inside the Lima VM. | ||
|
|
||
| ### Applying Changes | ||
|
|
||
| Restart the agent API service to pick up changes: | ||
|
|
||
| ```bash | ||
| systemctl --user restart flow-control-agent.service | ||
| ``` | ||
|
|
||
| ### Updating the GraphQL Schema | ||
|
|
||
| The auto-generated GraphQL schema is checked into the repo. After making changes to the GraphQL API, regenerate it with: | ||
|
|
||
| ```bash | ||
| cargo build -p flow-client --features generate | ||
| ``` | ||
|
|
||
| ### Updating sqlx query cache | ||
|
|
||
| After adding / modifying SQL queries, regenerate the checked-in sqlx query cache so that offline compilation works: | ||
|
|
||
| ```bash | ||
| cargo sqlx prepare --workspace | ||
| ``` | ||
|
|
||
| ### Updating test snapshots | ||
|
|
||
| Tests use `insta` for snapshot testing. After making changes that affect test output, review and accept updated snapshots with: | ||
|
|
||
| ```bash | ||
| cargo insta review -p control-plane-api | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
crates/control-plane-api/src/server/public/graphql/alert_types.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| use models::status::AlertType; | ||
|
|
||
| #[derive(Debug, Default)] | ||
| pub struct AlertTypesQuery; | ||
|
|
||
| /// Describes an alert type with user-facing metadata. | ||
| #[derive(Debug, Clone, async_graphql::SimpleObject)] | ||
| pub struct AlertTypeInfo { | ||
| /// The alert type identifier. | ||
| alert_type: AlertType, | ||
| /// A user-facing description of what this alert type means. | ||
| description: String, | ||
| /// A short, user-facing alert type name. | ||
| display_name: String, | ||
| /// An indication of whether the alert type is subscribed to by default. | ||
| is_default: bool, | ||
| /// An indication of whether the alert type is considered to be a system alert. | ||
| is_system_alert: bool, | ||
| } | ||
|
|
||
| #[async_graphql::Object] | ||
| impl AlertTypesQuery { | ||
| /// Returns all possible alert types with their user-facing metadata. | ||
| async fn alert_types(&self) -> Vec<AlertTypeInfo> { | ||
| AlertType::all() | ||
| .iter() | ||
| .map(|at| AlertTypeInfo { | ||
| alert_type: *at, | ||
| description: at.description().to_string(), | ||
| display_name: at.display_name().to_string(), | ||
| is_default: at.is_default(), | ||
| is_system_alert: at.is_system_alert(), | ||
| }) | ||
| .collect() | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kiahna-tucker @travjenkins