I have a nextjs(client side) project,
I followed this to subscribe to my graphql subscription but I got
"WebSocket implementation missing; on Node you can import WebSocket from 'ws';
and pass webSocketImpl: WebSocket
to createClient
"
, it seems to it wants me to provide a websocket implementation (is't websocket api implemented in browsers?!)(shouldn't it be in their docs?), any way I don't want to add apollo to my dependencies if it's your answer.
here is the impementation of the createClient that cause the Error
https://github.com/enisdenjo/graphql-ws/blob/abd6d6ef1b97a4de1214cdafc9002f2c63cdb100/src/client.ts#L512-L535
If it helps this is the prefered stack (graphql-codegen, react-query, graphql-request, graphql-ws)
even here no webSocketImpl
is provides for createClient
thanks in advance
Since I'm new to js and frontend dev I was writing the code in the main block of the nextjs component and not in some hook like useEffect and this triggers the graphql-ws that this environment is server side and not a browser (I'm still not sure if this is the right behavior to have)