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] 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 {