Skip to content

Commit

Permalink
feat: add support for variables in subgraphRequest function
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Aug 20, 2024
1 parent 04b881d commit 4a1d95a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,16 @@ export async function multicall(
}

export async function subgraphRequest(url: string, query, options: any = {}) {
const body: Record<string, any> = { query: jsonToGraphQLQuery({ query }) };
if (body) body.variables = options.variables;
const res = await fetch(url, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
...options?.headers
},
body: JSON.stringify({ query: jsonToGraphQLQuery({ query }) })
body: JSON.stringify(body)
});
let responseData: any = await res.text();
try {
Expand Down

0 comments on commit 4a1d95a

Please sign in to comment.