Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { WebSocketLink } from 'apollo-link-ws';
import { getMainDefinition } from 'apollo-utilities';
import { App } from './App';
const wsLink = new WebSocketLink({
uri: `ws://localhost:8085/query`,
options: {
reconnect: true
}
});
const httpLink = new HttpLink({ uri: 'http://localhost:8085/query' });
// depending on what kind of operation is being sent
const link = split(
// split based on operation type
({ query }) => {
const { kind, operation } = getMainDefinition(query);
return kind === 'OperationDefinition' && operation === 'subscription';
},
wsLink,
httpLink,
);
const apolloClient = new ApolloClient({
link: link,
cache: new InMemoryCache(),
});
if (module.hot) {
module.hot.accept('./App', () => {
const httpLink = new HttpLink({
uri: "http://localhost:4000/graphql",
headers: {
Origin: "http://localhost:4000",
},
});
const wsLink = new WebSocketLink({
uri: `ws://localhost:4000/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(),
});
headers: {
Origin: `${https}://${hostname}`,
},
});
const wsLink = process.browser
? new WebSocketLink({
uri: `${wss}://${hostname}/graphql`,
options: {
reconnect: true,
},
})
: null;
const splitLink = process.browser
? split(
({ query }) => {
const definition = getMainDefinition(query);
return definition.kind === "OperationDefinition" && definition.operation === "subscription";
},
wsLink,
httpLink
)
: httpLink;
const client = new ApolloClient({
link: splitLink,
cache: new InMemoryCache(),
});
const SupersenseApp = ({ Component, pageProps }: AppProps) => {
return (