Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

feat: add subscriptions for team invitations added and removed

Andrew Bastind9e5d4aec55d
diff --git a/packages/hoppscotch-app/components/teams/Invite.vue b/packages/hoppscotch-app/components/teams/Invite.vue
index 0354c67e3..e6fc08b99 100644
--- a/packages/hoppscotch-app/components/teams/Invite.vue
+++ b/packages/hoppscotch-app/components/teams/Invite.vue
@@ -296,14 +296,24 @@
</template>
<script setup lang="ts">
-import { watch, ref, reactive, useContext } from "@nuxtjs/composition-api"
+import {
+ watch,
+ ref,
+ reactive,
+ useContext,
+ computed,
+} from "@nuxtjs/composition-api"
import * as T from "fp-ts/Task"
import * as E from "fp-ts/Either"
import * as A from "fp-ts/Array"
import * as O from "fp-ts/Option"
import { flow, pipe } from "fp-ts/function"
import { Email, EmailCodec } from "../../helpers/backend/types/Email"
-import { TeamMemberRole } from "../../helpers/backend/graphql"
+import {
+ TeamInvitationAddedDocument,
+ TeamInvitationRemovedDocument,
+ TeamMemberRole,
+} from "../../helpers/backend/graphql"
import {
createTeamInvitation,
CreateTeamInvitationErrors,
@@ -342,6 +352,26 @@ const pendingInvites = useGQLQuery<
variables: reactive({
teamID: props.editingTeamID,
}),
+ updateSubs: computed(() =>
+ !props.editingTeamID
+ ? []
+ : [
+ {
+ key: 3,
+ query: TeamInvitationAddedDocument,
+ variables: {
+ teamID: props.editingTeamID,
+ },
+ },
+ {
+ key: 4,
+ query: TeamInvitationRemovedDocument,
+ variables: {
+ teamID: props.editingTeamID,
+ },
+ },
+ ]
+ ),
defer: true,
})
diff --git a/packages/hoppscotch-app/helpers/backend/gql/subscriptions/TeamInvitationAdded.graphql b/packages/hoppscotch-app/helpers/backend/gql/subscriptions/TeamInvitationAdded.graphql
new file mode 100644
index 000000000..878ec130b
--- /dev/null
+++ b/packages/hoppscotch-app/helpers/backend/gql/subscriptions/TeamInvitationAdded.graphql
@@ -0,0 +1,5 @@
+subscription TeamInvitationAdded($teamID: ID!) {
+ teamInvitationAdded(teamID: $teamID) {
+ id
+ }
+}
\ No newline at end of file
diff --git a/packages/hoppscotch-app/helpers/backend/gql/subscriptions/TeamInvitationRemoved.graphql b/packages/hoppscotch-app/helpers/backend/gql/subscriptions/TeamInvitationRemoved.graphql
new file mode 100644
index 000000000..d90488f9c
--- /dev/null
+++ b/packages/hoppscotch-app/helpers/backend/gql/subscriptions/TeamInvitationRemoved.graphql
@@ -0,0 +1,3 @@
+subscription TeamInvitationRemoved($teamID: ID!) {
+ teamInvitationRemoved(teamID: $teamID)
+}
\ No newline at end of file