Skip to content

Commit 901305a

Browse files
wa0x6eChaituVR
andauthored
feat: add support for variables in subgraphRequest function (#1047)
* feat: add support for variables in subgraphRequest function * Update src/utils.ts * v0.12.5 --------- Co-authored-by: Chaitanya <[email protected]>
1 parent 75f1a0b commit 901305a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@snapshot-labs/snapshot.js",
3-
"version": "0.12.4",
3+
"version": "0.12.5",
44
"repository": "snapshot-labs/snapshot.js",
55
"license": "MIT",
66
"main": "dist/snapshot.cjs.js",

src/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,16 @@ export async function multicall(
254254
}
255255

256256
export async function subgraphRequest(url: string, query, options: any = {}) {
257+
const body: Record<string, any> = { query: jsonToGraphQLQuery({ query }) };
258+
if (options.variables) body.variables = options.variables;
257259
const res = await fetch(url, {
258260
method: 'POST',
259261
headers: {
260262
Accept: 'application/json',
261263
'Content-Type': 'application/json',
262264
...options?.headers
263265
},
264-
body: JSON.stringify({ query: jsonToGraphQLQuery({ query }) })
266+
body: JSON.stringify(body)
265267
});
266268
let responseData: any = await res.text();
267269
try {

0 commit comments

Comments
 (0)