From 4a1d95a7474bc1880107d6697b9c42001f2530c7 Mon Sep 17 00:00:00 2001 From: Wan Qi Chen <495709+wa0x6e@users.noreply.github.com> Date: Wed, 21 Aug 2024 00:29:50 +0900 Subject: [PATCH 1/3] feat: add support for variables in subgraphRequest function --- src/utils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 2feda326e..3bebf9d2c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -254,6 +254,8 @@ export async function multicall( } export async function subgraphRequest(url: string, query, options: any = {}) { + const body: Record = { query: jsonToGraphQLQuery({ query }) }; + if (body) body.variables = options.variables; const res = await fetch(url, { method: 'POST', headers: { @@ -261,7 +263,7 @@ export async function subgraphRequest(url: string, query, options: any = {}) { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify({ query: jsonToGraphQLQuery({ query }) }) + body: JSON.stringify(body) }); let responseData: any = await res.text(); try { From 1cc543d341f1df9619da1825f1767517f8f5b42b Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Tue, 20 Aug 2024 23:50:21 +0530 Subject: [PATCH 2/3] Update src/utils.ts --- src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index afb53f420..a3115c826 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -255,7 +255,7 @@ export async function multicall( export async function subgraphRequest(url: string, query, options: any = {}) { const body: Record = { query: jsonToGraphQLQuery({ query }) }; - if (body) body.variables = options.variables; + if (options.variables) body.variables = options.variables; const res = await fetch(url, { method: 'POST', headers: { From 0ecde971f838d044f3bf03241163cba9db82c7c6 Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Wed, 21 Aug 2024 13:45:37 +0530 Subject: [PATCH 3/3] v0.12.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 197e8ee6c..ccea37924 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@snapshot-labs/snapshot.js", - "version": "0.12.4", + "version": "0.12.5", "repository": "snapshot-labs/snapshot.js", "license": "MIT", "main": "dist/snapshot.cjs.js",