Upon request I'm working on a scraping application that lightly scrapes a external website that makes use of graphql and the graphql-ws package (so graphql over a websocket). I've never used any sort of graphql before.
The site I'm trying to gain access to makes use of a session cookie to authenticate users. Now I'm trying to simulate this in my NodeJS application. I just can't find a way of setting a cookie for the initial http request for opening the socket. Below is the code I currently have.
Code
import { createClient } from 'graphql-ws';
import WebSocket from 'ws';
const client = createClient({
url: 'wss://target.io/graphql',
webSocketImpl: WebSocket,
on: {
connected: (socket) => {
console.log("Connected!");
},
},
});
(async () => {
// Create subscription
})();
This in itself works fine, as long as I don't need to use any authenticated subscriptions. How can I make it so a session cookie is set before establishing a connection?