i am trying to fetch data to the client through subscriptions from a graphql server. in order to do so we need to establish a websocket connection first. However when I try to do it i get the following error back
error:
WebSocket connection to 'ws://localhost:8888/' failed: Unexpected response code: 400
liveReload — index.js:53
client side code:
import { WebSocketLink } from "@apollo/client/link/ws";
const wsLink = new WebSocketLink({
uri: "ws://localhost:8888",
options: {
reconnect: false
}
});
i am 100% certain that localhost:8888 is where the graphql server is hosted.i have tried both in safari and firefox
you have to specify the subscription path explicitly on the graphql server declaration as below