I'm trying to upgrade our NestJS GraphQL subscriptions server to utilize graphql-ws rather than the current subscriptions-transport-ws (as suggested by the NestJS documentation). I upgraded the NestJS version to
"@nestjs/core": "^8.0.6", "@nestjs/graphql": "^9.0.4", "@nestjs/platform-express": "^8.0.6", "graphql": "^15.5.3", "graphql-tools": "^8.2.0", "apollo-server-express": "^3.3.0", And after, I added the subscriptions option to the App.Module:
GraphQLModule.forRoot({ autoSchemaFile: true, sortSchema: true, playground: true, installSubscriptionHandlers: true, subscriptions: { 'graphql-ws': true }, }), However when I subscribe (in playground) to a previously working subscription, I get:
{ "error": "Could not connect to websocket endpoint ws://localhost:8880/graphql. Please check if the endpoint url is correct." } And in the console I get:
WebSocket protocol error occured. It was most likely caused due to an unsupported subprotocol "graphql-ws" requested by the client. graphql-ws implements exclusively the "graphql-transport-ws" subprotocol, please make sure that the client implements it too. Things I have tried:
- Adding the
graphql-wspackage - Upgrading the NestJS version again
- Removing the
installSubscriptionHandlersoption from config - Setting
graphql-wsconfigs instead of passingtrue - Using the
WebSocket Test ClientGoogle Chrome extension instead of Playground
But none have worked. Sorry for the long post. How can I fix this?