chore(deps): remove deprecated subscriptions-transport-ws (#2922)
Removes the deprecated `subscriptions-transport-ws` package (Renovate dependency dashboard #49). The package is unmaintained and was only reachable through the Apollo `WebSocketLink` in `app/plugins/apollo.ts`. The schema has no `Subscription` type and no subscription operations are defined, so the ws `split()` branch was dead code. - Drop `WebSocketLink`, the `split()` routing, `getMainDefinition`, and `wsUrl` from `app/plugins/apollo.ts` - Remove the direct `subscriptions-transport-ws` dependency Verified with `npm run build` (green) and eslint (clean). Note: the package lingers in the lockfile as an optional peer dep of `@apollo/client` v3; it disappears with the Apollo Client v4 upgrade, which removes `@apollo/client/link/ws` entirely. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Reviewed-on: #2922
This commit was merged in pull request #2922.
This commit is contained in:
+2
-28
@@ -1,7 +1,5 @@
|
||||
import { ApolloClient, ApolloLink, createHttpLink, from, InMemoryCache, split } from '@apollo/client/core'
|
||||
import { ApolloClient, ApolloLink, createHttpLink, from, InMemoryCache } from '@apollo/client/core'
|
||||
import { setContext } from '@apollo/client/link/context'
|
||||
import { WebSocketLink } from '@apollo/client/link/ws'
|
||||
import { getMainDefinition } from '@apollo/client/utilities'
|
||||
import type { GetTokenSilentlyOptions } from '@auth0/auth0-spa-js'
|
||||
import type { Auth0VueClient } from '@auth0/auth0-vue'
|
||||
import { SpanKind, TraceFlags } from '@opentelemetry/api'
|
||||
@@ -11,7 +9,6 @@ import { defineNuxtPlugin, useNuxtApp } from '#app'
|
||||
import { envConfig } from '~/utils/environment'
|
||||
|
||||
const apiUrl = envConfig(window.location.hostname).apiUrl
|
||||
const wsUrl = apiUrl.replace(/^http/, 'ws')
|
||||
|
||||
const cache = new InMemoryCache({
|
||||
typePolicies: {
|
||||
@@ -42,19 +39,6 @@ const httpLink = createHttpLink({
|
||||
uri: apiUrl,
|
||||
})
|
||||
|
||||
const wsLink = new WebSocketLink({
|
||||
uri: wsUrl,
|
||||
options: {
|
||||
reconnect: true,
|
||||
lazy: true,
|
||||
connectionParams: () => {
|
||||
return getToken({}).then((token) => ({
|
||||
authToken: token,
|
||||
}))
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const authLink = setContext(async (_, { headers }) => {
|
||||
return await getToken({}).then((token) => ({
|
||||
headers: {
|
||||
@@ -86,17 +70,7 @@ const createSpanLink = new ApolloLink((operation, forward) => {
|
||||
const link =
|
||||
from([
|
||||
createSpanLink,
|
||||
split(
|
||||
({ query }) => {
|
||||
const definition = getMainDefinition(query)
|
||||
return (
|
||||
definition.kind === 'OperationDefinition' &&
|
||||
definition.operation === 'subscription'
|
||||
)
|
||||
},
|
||||
authLink.concat(wsLink),
|
||||
authLink.concat(httpLink),
|
||||
),
|
||||
authLink.concat(httpLink),
|
||||
])
|
||||
|
||||
const instance = new ApolloClient({
|
||||
|
||||
Reference in New Issue
Block a user