diff --git a/src/runtime/composables/gql-subscription.ts b/src/runtime/composables/gql-subscription.ts index 9a663bf..368facd 100644 --- a/src/runtime/composables/gql-subscription.ts +++ b/src/runtime/composables/gql-subscription.ts @@ -1,3 +1,5 @@ +import type { Client } from 'graphql-ws'; + import { subscription } from 'gql-query-builder'; import gql from 'graphql-tag'; import { useNuxtApp } from 'nuxt/app'; @@ -137,13 +139,13 @@ export async function gqlSubscription(method: string, options: IGraphQL const data = ref(null); const error = ref(null); const loading = ref(true); - let subscriptionState = null; + let subscriptionState: Client | null = null; const start = () => { loading.value = true; error.value = null; - subscriptionState = _wsClient.subscribe( + subscriptionState = (_wsClient as any).subscribe( { query: queryBody.query, variables: variables }, { complete: () => { @@ -168,7 +170,7 @@ export async function gqlSubscription(method: string, options: IGraphQL const stop = () => { if (subscriptionState) { - subscriptionState.unsubscribe(); + subscriptionState.dispose(); subscriptionState = null; } }; diff --git a/src/runtime/plugins/ws.client.ts b/src/runtime/plugins/ws.client.ts index b425322..41cc218 100644 --- a/src/runtime/plugins/ws.client.ts +++ b/src/runtime/plugins/ws.client.ts @@ -20,13 +20,13 @@ export default defineNuxtPlugin({ closed: async (event) => { const { checkTokenAndRenew } = useAuth(); - if (event.code === 4500) { + if (event?.code === 4500) { await checkTokenAndRenew(); } }, }, retryAttempts: 5, - url: wsUrl, + url: wsUrl as string, }); nuxtApp._wsClient = client;