From 9f17ecf1b4096acdf4b62873a289e0a3e820b2a9 Mon Sep 17 00:00:00 2001 From: CryptoGraffe Date: Wed, 1 Nov 2023 22:55:42 -0700 Subject: [PATCH] another try --- src/app/api/zeus/index.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/api/zeus/index.ts b/src/app/api/zeus/index.ts index 8d8ac97..6087b97 100644 --- a/src/app/api/zeus/index.ts +++ b/src/app/api/zeus/index.ts @@ -7,14 +7,18 @@ export const HOST = "http://localhost:8080/v1/graphql" export const HEADERS = {} -import { createClient, type Sink } from 'graphql-ws'; // keep +import { createClient, type Sink } from 'graphql-ws'; export const apiSubscription = (options: chainOptions) => { - - // const headers : Record = {}; + + const h = options[1]?.headers; + // const passedHeaders : HeadersInit = /*options[1]?.headers ??*/ new Headers(); + // const h = {'authorization':passedHeaders['authorization'] ?? '','x-hasura-role':passedHeaders['x-hasura-role'] ?? ''}; + // const empty : [string, string][] = []; + // const headers : HeadersInit = passedHeaders ? passedHeaders : empty; const client = createClient({ url: String(options[0]), - // connectionParams: Object.fromEntries(new Headers(options[1]?.headers).entries()), + connectionParams: h ? Object.fromEntries(new Headers(h).entries()) : undefined, }); const ws = new Proxy(