0

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

1 Answer 1

0

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)

answered Apr 20, 2023 at 15:30
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.