Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

248
Views
GraphqlWS setting a cookie before establishing the websocket connection

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?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!