Skip to content

Commit

Permalink
Fix API issue from Alert Status (#1156)
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Ullyott <[email protected]>
  • Loading branch information
Orrison authored Dec 5, 2024
1 parent e841d7f commit f5a8d32
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 5 deletions.
106 changes: 106 additions & 0 deletions app-modules/alert/graphql/alert-status.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
type AlertStatus @model(class: "AdvisingApp\\Alert\\Models\\AlertStatus") {
"Unique primary key."
id: UUID!

"The Classification of the alert status."
classification: SystemAlertStatusClassification!

"The name of the alert status."
name: String!

"The order of the alert status."
order: Int!

"Whether or not the alert status is the default."
is_default: Boolean!

"The created datetime of the alert."
created_at: DateTime

"The updated datetime of the alert."
updated_at: DateTime

"The deleted datetime of the alert."
deleted_at: DateTime
}

input AlertStatusesQuery {
id: UUID
classification: SystemAlertStatusClassification
name: String
order: Int
is_default: Boolean
created_at: DateTime
updated_at: DateTime
deleted_at: DateTime
}

type AlertStatusQueries {
"Find a single alert status by an identifying attribute."
find(
"The value of the attribute to match."
id: UUID!
@whereKey
@rules(apply: ["required", "uuid", "exists:alert_statuses"])
): AlertStatus @find @softDeletes @canResolved(ability: "view")

"List multiple alert statuses."
list(where: AlertStatusesQuery @searchBy): [AlertStatus!]!
@paginate
@softDeletes
@canModel(ability: "viewAny")
}

extend type Query {
alertStatus: AlertStatusQueries! @namespaced
}

input CreateAlertStatusInput {
"The name of the alert status."
name: String! @rules(apply: ["required", "string", "max:255"])

"The classification of the alert status."
classification: SystemAlertStatusClassification!

# Add the ability to set default later
}

input UpdateAlertStatusInput {
"The name of the alert status."
name: String! @rules(apply: ["required", "string", "max:255"])

"The classification of the alert status."
classification: SystemAlertStatusClassification!

# Add the ability to set default later
}

type AlertStatusMutations {
"Create an alert status."
create(input: CreateAlertStatusInput! @spread): AlertStatus!
@create
@canModel(ability: "create")

"Update an existing alert status."
update(
"The identifier of the alert status you would like to update."
id: UUID!
@whereKey
@rules(apply: ["required", "uuid", "exists:alert_statuses"])

"The fields you would like to update."
input: UpdateAlertStatusInput! @spread
): AlertStatus! @canFind(ability: "update", find: "id") @update

"Delete an existing alert status."
delete(
"The identifier of the alert status you would like to delete."
id: UUID!
@whereKey
@rules(apply: ["required", "uuid", "exists:alert_statuses"])
): AlertStatus @canFind(ability: "delete", find: "id") @delete
}

extend type Mutation {
alertStatus: AlertStatusMutations! @namespaced
}
8 changes: 4 additions & 4 deletions app-modules/alert/graphql/alert.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Alert @model(class: "AdvisingApp\\Alert\\Models\\Alert") {
severity: AlertSeverity!

"The status of the alert."
status: AlertStatus!
status: AlertStatus! @belongsTo

"The suggested intervention for the alert."
suggested_intervention: String!
Expand All @@ -39,7 +39,7 @@ input AlertsQuery {
concern_type: EducatableType
description: String
severity: AlertSeverity
status: AlertStatus
status: AlertStatusesQuery
suggested_intervention: String
created_at: DateTime
updated_at: DateTime
Expand Down Expand Up @@ -85,7 +85,7 @@ input CreateAlertInput {
severity: AlertSeverity! @rules(apply: ["required"])

"The status of the alert."
status: AlertStatus! @rules(apply: ["required"])
status_id: UUID! @rules(apply: ["required", "string", "in:alert_statuses"])

"The suggested intervention for the alert."
suggested_intervention: String! @rules(apply: ["required", "string"])
Expand All @@ -99,7 +99,7 @@ input UpdateAlertInput {
severity: AlertSeverity @rules(apply: ["filled"])

"The status of the alert."
status: AlertStatus @rules(apply: ["filled"])
status_id: UUID @rules(apply: ["filled", "string", "in:alert_statuses"])

"The suggested intervention for the alert."
suggested_intervention: String @rules(apply: ["filled", "string"])
Expand Down
2 changes: 1 addition & 1 deletion app-modules/alert/src/Providers/AlertServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected function registerEvents(): void

protected function registerGraphQL(): void
{
$this->discoverSchema(__DIR__ . '/../../graphql/alert.graphql');
$this->discoverSchema(__DIR__ . '/../../graphql/*');

$this->registerEnum(AlertSeverity::class);
$this->registerEnum(SystemAlertStatusClassification::class);
Expand Down

0 comments on commit f5a8d32

Please sign in to comment.