Skip to content
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

Fix graphql subscription #392

Merged
merged 1 commit into from
Dec 21, 2023
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
109 changes: 70 additions & 39 deletions app-modules/notification/graphql/subscription.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,90 @@ type UserSubscription
@model(class: "AdvisingApp\\Notification\\Models\\Subscription") {
"Unique primary key."
id: UUID!
"The user related to this subscription."
"The User related to this subscription."
user: User! @belongsTo
"The subscribable the user is subscribed to."
"The Subscribable the User is subscribed to."
subscribable: Educatable! @morphTo
"The created date of the subscription."
created_at: DateTime
"The updated date of the subscription."
updated_at: DateTime
}

extend type Query {
"Get a subscription by its primary key."
userSubscription(
"Search by primary key."
id: UUID! @whereKey
input UserSubscriptionSubscribablesQuery {
student: StudentsQuery
prospect: ProspectsQuery
}

input SubscriptionsQuery {
id: UUID
user: UserQuery
subscribable: UserSubscriptionSubscribablesQuery @morphToRelation
subscribable_id: EducatableId
subscribable_type: EducatableType
created_at: DateTime
updated_at: DateTime
}

type UserSubscriptionQueries {
"Find a single subscription by an identifying attribute."
find(
"The value of the attribute to match."
id: UUID!
@whereKey
@rules(apply: ["required", "uuid", "exists:subscriptions"])
): UserSubscription @find @canResolved(ability: "view")

"Get all subscriptions."
userSubscriptions: [UserSubscription!]!
"List multiple subscriptions."
list(where: SubscriptionsQuery @searchBy): [UserSubscription!]!
@paginate
@canModel(ability: "viewAny")
}

extend type Mutation {
"Create a new subscription."
createUserSubscription(
"The user to subscribe."
user_id: UUID!
@rules(
apply: [
"required"
"exists:users,id"
"AdvisingApp\\Notification\\Rules\\UniqueSubscriptionRule"
]
)

"The subscribable to subscribe to."
subscribable_id: EducatableId!
@rules(
apply: [
"required"
"AdvisingApp\\Notification\\Rules\\SubscribableIdExistsRule"
]
)

"The type of subscribable to subscribe to."
subscribable_type: String!
@rules(apply: ["required", "in:student,prospect"])
): UserSubscription! @create @canModel(ability: "create")

"Delete an existing subscription."
deleteUserSubscription(
extend type Query {
subscription: UserSubscriptionQueries! @namespaced
}

input CreateUserSubscriptionInput {
"The user to subscribe."
user_id: UUID!
@rules(
apply: [
"required"
"exists:users,id"
"AdvisingApp\\Notification\\Rules\\UniqueSubscriptionRule"
]
)

"The subscribable to subscribe to."
subscribable_id: EducatableId!
@rules(
apply: [
"required"
"AdvisingApp\\Notification\\Rules\\SubscribableIdExistsRule"
]
)

"The type of subscribable to subscribe to."
subscribable_type: EducatableType!
@rules(apply: ["required", "in:student,prospect"])
}

type UserSubscriptionMutations {
"Subscribe a User to a Subscribable."
subscribe(input: CreateUserSubscriptionInput! @spread): UserSubscription!
@create
@canModel(ability: "create")

"Unsubscribe a User from a Subscribable."
unsubscribe(
"The primary key of the subscription."
id: UUID! @whereKey
id: UUID!
@whereKey
@rules(apply: ["required", "uuid", "exists:subscriptions"])
): UserSubscription @delete @canFind(ability: "delete", find: "id")
}

extend type Mutation {
subscription: UserSubscriptionMutations! @namespaced
}
91 changes: 0 additions & 91 deletions app-modules/notifications/graphql/subscription.graphql

This file was deleted.