Skip to content

Commit

Permalink
feat: add support for variables in subgraphRequest function (#1047)
Browse files Browse the repository at this point in the history
* feat: add support for variables in subgraphRequest function

* Update src/utils.ts

* v0.12.5

---------

Co-authored-by: Chaitanya <yourchaitu@gmail.com>
  • Loading branch information
wa0x6e and ChaituVR committed Aug 21, 2024
1 parent 75f1a0b commit 901305a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
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 (options.variables) 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 901305a

Please sign in to comment.