-
Actual Behaviour
My code import { InMemoryCache, ApolloClient, ApolloProvider, split, HttpLink } from '@apollo/client';
import { getMainDefinition } from '@apollo/client/utilities';
import { ChakraProvider } from '@chakra-ui/react';
import { GraphQLWsLink } from '@apollo/client/link/subscriptions';
import { createClient } from 'graphql-ws';
const httpLink = new HttpLink({
uri: 'http://localhost:9000/v1/graphql'
});
const wsLink = new GraphQLWsLink(createClient({
url: "ws://localhost:9000/v1/graphql",
}));
const splitLink = split(
({ query }) => {
const definition = getMainDefinition(query);
return (
definition.kind === 'OperationDefinition' &&
definition.operation === 'subscription'
);
},
wsLink,
httpLink,
);
const client = new ApolloClient({
cache: new InMemoryCache(),
link: splitLink,
});
function MyApp({ Component, pageProps }: AppProps) {
return <QueryStoreProvider>
<ApolloProvider client={client}>
<ChakraProvider>
<Component {...pageProps} />
</ChakraProvider>
</ApolloProvider>
</QueryStoreProvider>
} Debug Information
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 9 replies
-
Hey, you're using the ESM version of |
Beta Was this translation helpful? Give feedback.
-
I use latest versions of graphql-ws and graphql. |
Beta Was this translation helpful? Give feedback.
-
I use nextjs. Maybe problem with SSR. |
Beta Was this translation helpful? Give feedback.
-
I tried to find solution, but spent more than 30 minutes. I don't understand how to wrap |
Beta Was this translation helpful? Give feedback.
-
Do you know, |
Beta Was this translation helpful? Give feedback.
Hey, you're using the ESM version of
graphql-ws
while using the CJS version ofgraphql
. The problem is either with your bundler orgraphql
version.