ОЛ
Size: a a a
ОЛ
K
ОЛ
ОЛ
𝘂
𝘂
K
ОЛ
𝘂
S
K
ОЛ
ОЛ
K
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
import { ApolloProvider, ApolloClient, InMemoryCache } from "@apollo/client";
import { split, HttpLink } from "@apollo/client";
import { getMainDefinition } from "@apollo/client/utilities";
import { WebSocketLink } from "@apollo/client/link/ws";
const httpLink = new HttpLink({
uri: "http://localhost:5000/graphql",
});
const wsLink = new WebSocketLink({
uri: "wss://localhost:5000/graphql",
options: {
reconnect: true,
},
});
const splitLink = split(
({ query }) => {
const definition = getMainDefinition(query);
return (
definition.kind === "OperationDefinition" &&
definition.operation === "subscription"
);
},
wsLink,
httpLink
);
const client = new ApolloClient({
link: splitLink,
cache: new InMemoryCache(),
});
ReactDOM.render(
<ApolloProvider client={client}>
<App />
</ApolloProvider>,
document.getElementById("root")
);
ОЛ
ОЛ
K