Meteor 3: ApolloGraphQL Subscription Setup? [SOLVED]

I had ApolloGraphQL working on localdev using port 4000 for subscriptions, but on Galaxy I only have access to the Meteor port, i.e. usually port 3000.

Now I have ApolloGraphQL queries working, but I haven’t gotten subscriptions nailed down yet.

Does anyone have ApolloGraphQL subscriptions working in production with Meteor 3, by any chance? If so could you share your client and server setup code?

I got it working, thanks to this code provided 2 years ago {!} by @minha.

WebApp.httpServer.on("upgrade", function upgrade(request, socket, head) {
    if (!request.url) {
        return;
    }
    switch (request.url) {
        case "/graphql":
            return wsServer.handleUpgrade(request, socket, head, function done(ws) {
                wsServer.emit("connection", ws, request);
            });
        default:
            break;
    }
});

I don’t know what this code is doing, or how @minha found it. :slight_smile: I’ve been researching how to do this setup over a period of quite a few weeks and never saw any reference to it except in that thread. Thanks @minha!

I’ll post my updated Apollo server and client code in this thread.

1 Like