From 1a19c028708067640c7eaa3da97e6662bb828808 Mon Sep 17 00:00:00 2001 From: CryptoGraffe Date: Wed, 1 Nov 2023 22:19:30 -0700 Subject: [PATCH 1/7] updating zeus --- src/app/api/zeus/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/api/zeus/index.ts b/src/app/api/zeus/index.ts index 03ac9f2..c0a8ce7 100644 --- a/src/app/api/zeus/index.ts +++ b/src/app/api/zeus/index.ts @@ -14,7 +14,7 @@ export const apiSubscription = (options: chainOptions) => { // const headers : Record = {}; const client = createClient({ url: String(options[0]), - // connectionParams: Object.fromEntries(new Headers(options[1]?.headers).entries()), + connectionParams: Object.fromEntries(new Headers(options[1]?.headers).entries()), }); const ws = new Proxy( @@ -81685,4 +81685,4 @@ type ZEUS_VARIABLES = { ["vouches_var_pop_order_by"]: ValueTypes["vouches_var_pop_order_by"]; ["vouches_var_samp_order_by"]: ValueTypes["vouches_var_samp_order_by"]; ["vouches_variance_order_by"]: ValueTypes["vouches_variance_order_by"]; -} \ No newline at end of file +} From 48eb16ec5cdea97a57ca00e80ab7c8dd5fe099ba Mon Sep 17 00:00:00 2001 From: CryptoGraffe Date: Wed, 1 Nov 2023 22:24:40 -0700 Subject: [PATCH 2/7] removing chained options --- src/app/api/zeus/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/api/zeus/index.ts b/src/app/api/zeus/index.ts index c0a8ce7..8d8ac97 100644 --- a/src/app/api/zeus/index.ts +++ b/src/app/api/zeus/index.ts @@ -14,7 +14,7 @@ export const apiSubscription = (options: chainOptions) => { // const headers : Record = {}; const client = createClient({ url: String(options[0]), - connectionParams: Object.fromEntries(new Headers(options[1]?.headers).entries()), + // connectionParams: Object.fromEntries(new Headers(options[1]?.headers).entries()), }); const ws = new Proxy( From 9f17ecf1b4096acdf4b62873a289e0a3e820b2a9 Mon Sep 17 00:00:00 2001 From: CryptoGraffe Date: Wed, 1 Nov 2023 22:55:42 -0700 Subject: [PATCH 3/7] 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( From 92db4b01db870b5ddd4f8c6c81f5e43bb9cdc092 Mon Sep 17 00:00:00 2001 From: CryptoGraffe Date: Wed, 1 Nov 2023 23:01:25 -0700 Subject: [PATCH 4/7] undefined check --- src/app/api/zeus/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/api/zeus/index.ts b/src/app/api/zeus/index.ts index 6087b97..d12329f 100644 --- a/src/app/api/zeus/index.ts +++ b/src/app/api/zeus/index.ts @@ -18,7 +18,8 @@ export const apiSubscription = (options: chainOptions) => { // const headers : HeadersInit = passedHeaders ? passedHeaders : empty; const client = createClient({ url: String(options[0]), - connectionParams: h ? Object.fromEntries(new Headers(h).entries()) : undefined, + + connectionParams: h !== undefined ? Object.fromEntries(new Headers(h).entries()) : undefined, }); const ws = new Proxy( From ef81ec31099bfe36ed0eb338d9426df47018353f Mon Sep 17 00:00:00 2001 From: CryptoGraffe Date: Wed, 1 Nov 2023 23:03:05 -0700 Subject: [PATCH 5/7] make it not optional --- src/app/api/zeus/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/api/zeus/index.ts b/src/app/api/zeus/index.ts index d12329f..0a2a9cb 100644 --- a/src/app/api/zeus/index.ts +++ b/src/app/api/zeus/index.ts @@ -10,7 +10,7 @@ export const HEADERS = {} import { createClient, type Sink } from 'graphql-ws'; export const apiSubscription = (options: chainOptions) => { - + 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'] ?? ''}; @@ -18,7 +18,7 @@ export const apiSubscription = (options: chainOptions) => { // const headers : HeadersInit = passedHeaders ? passedHeaders : empty; const client = createClient({ url: String(options[0]), - + connectionParams: h !== undefined ? Object.fromEntries(new Headers(h).entries()) : undefined, }); From dee1b87b2da4cb6e66e0e4915fe18f875b92f599 Mon Sep 17 00:00:00 2001 From: CryptoGraffe Date: Wed, 1 Nov 2023 23:05:03 -0700 Subject: [PATCH 6/7] hack mode --- src/app/api/zeus/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/api/zeus/index.ts b/src/app/api/zeus/index.ts index 0a2a9cb..f845cb7 100644 --- a/src/app/api/zeus/index.ts +++ b/src/app/api/zeus/index.ts @@ -11,7 +11,7 @@ import { createClient, type Sink } from 'graphql-ws'; export const apiSubscription = (options: chainOptions) => { - const h = options[1]?.headers; + 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][] = []; @@ -19,7 +19,7 @@ export const apiSubscription = (options: chainOptions) => { const client = createClient({ url: String(options[0]), - connectionParams: h !== undefined ? Object.fromEntries(new Headers(h).entries()) : undefined, + connectionParams: h !== undefined ? Object.fromEntries(new Headers(h as HeadersInit).entries()) : undefined, }); const ws = new Proxy( From 0a771a14933517baf8be932c4dab82bed14bfb8d Mon Sep 17 00:00:00 2001 From: CryptoGraffe Date: Wed, 1 Nov 2023 23:06:53 -0700 Subject: [PATCH 7/7] undefined check --- src/app/api/zeus/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/api/zeus/index.ts b/src/app/api/zeus/index.ts index f845cb7..1eb116f 100644 --- a/src/app/api/zeus/index.ts +++ b/src/app/api/zeus/index.ts @@ -11,7 +11,10 @@ import { createClient, type Sink } from 'graphql-ws'; export const apiSubscription = (options: chainOptions) => { - const h = options[1].headers; + const h = options[1]?.headers; + if (h === undefined) { + throw new Error('auth headers required'); + } // const passedHeaders : HeadersInit = /*options[1]?.headers ??*/ new Headers(); // const h = {'authorization':passedHeaders['authorization'] ?? '','x-hasura-role':passedHeaders['x-hasura-role'] ?? ''}; // const empty : [string, string][] = [];