remove framasoft/absinthe-socket dependancy packages - #1814

This commit is contained in:
Laurent GAY
2025-12-05 12:32:09 +01:00
parent 65a850994f
commit 61719d4d32
5 changed files with 10 additions and 270 deletions

View File

@@ -1,25 +0,0 @@
import { Socket as PhoenixSocket } from "phoenix";
import { create } from "@framasoft/socket";
import { createAbsintheSocketLink } from "@framasoft/socket-apollo-link";
import { AUTH_ACCESS_TOKEN } from "@/constants";
import { GRAPHQL_API_ENDPOINT } from "@/api/_entrypoint";
const httpServer = GRAPHQL_API_ENDPOINT || "http://localhost:4000";
const webSocketPrefix = import.meta.env.PROD ? "wss" : "ws";
const wsEndpoint = `${webSocketPrefix}${httpServer.substring(
httpServer.indexOf(":")
)}/graphql_socket`;
const phoenixSocket = new PhoenixSocket(wsEndpoint, {
params: () => {
const token = localStorage.getItem(AUTH_ACCESS_TOKEN);
if (token) {
return { token };
}
return {};
},
});
const absintheSocket = create(phoenixSocket);
export default createAbsintheSocketLink(absintheSocket);

View File

@@ -1,7 +1,5 @@
import { from, split } from "@apollo/client/core";
import { from } from "@apollo/client/core";
import { RetryLink } from "@apollo/client/link/retry";
import { getMainDefinition } from "@apollo/client/utilities";
import absintheSocketLink from "./absinthe-socket-link";
import { authMiddleware } from "./auth";
import errorLink from "./error-link";
import { uploadLink } from "./absinthe-upload-socket-link";
@@ -9,23 +7,10 @@ import { removeTypenameFromVariables } from "@apollo/client/link/remove-typename
const retryLink = new RetryLink();
const link = split(
// split based on operation type
({ query }) => {
const definition = getMainDefinition(query);
return (
definition.kind === "OperationDefinition" &&
definition.operation === "subscription"
);
},
absintheSocketLink,
uploadLink
);
export const fullLink = from([
removeTypenameFromVariables(),
retryLink,
errorLink,
authMiddleware,
link ?? uploadLink,
uploadLink,
]);

View File

@@ -1,5 +1 @@
declare module "@framasoft/socket";
declare module "@framasoft/socket-apollo-link";
declare module "apollo-absinthe-upload-link";