Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.3/5.0 broken on Node.js with Typescript: WebSocket is not defined #385

Closed
Qix- opened this issue Sep 7, 2022 · 6 comments
Closed

4.3/5.0 broken on Node.js with Typescript: WebSocket is not defined #385

Qix- opened this issue Sep 7, 2022 · 6 comments

Comments

@Qix-
Copy link

Qix- commented Sep 7, 2022

WebSocket functionality was introduced in #330 but assumed that WebSocket was available everywhere. This is only the case in the DOM - Node does not have WebSocket available in the global scope. This makes typescript compilation fail in all cases.

Reference comment (cc @SimenB):
#330 (comment)

@Qix- Qix- changed the title 5.0.0 breaks on Node.js with Typescript: WebSocket is not defined 4.3/5.0 break on Node.js with Typescript: WebSocket is not defined Sep 7, 2022
@Qix-
Copy link
Author

Qix- commented Sep 7, 2022

Looks like this breaking change was actually introduced in a minor bump 4.3.

@lcanavesio
Copy link

lcanavesio commented Sep 8, 2022

I have the same problem!

node_modules/graphql-request/dist/graphql-ws.d.ts:19:25 - error TS2304: Cannot find name 'WebSocket'.

19 constructor(socket: WebSocket, { onInit, onAcknowledged, onPing, onPong }: SocketHandler);
~~~~~~~~~

Found 1 error(s).

I fixed for now with "skipLibCheck": true In tsconfig.json

@Qix- Qix- changed the title 4.3/5.0 break on Node.js with Typescript: WebSocket is not defined 4.3/5.0 broken on Node.js with Typescript: WebSocket is not defined Sep 8, 2022
@mhdalmajid
Copy link

same Issue here
node 16
"graphql-request": "^5.0.0",

@fedegant
Copy link

Yes, this is a problem. We need to be able to use "graphql-request": "^5.0.0" in nodejs without having to include DOM in the ts.config libs

@irondsd
Copy link

irondsd commented Nov 27, 2022

"skipLibCheck": true helped, even though it's not a good way to fix things.

SimenB added a commit to SimenB/graphql-request that referenced this issue May 30, 2023
@ckifer
Copy link

ckifer commented Sep 15, 2023

This is still an issue. Bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants