Skip to content

Commit 0b75e03

Browse files
ChaituVRmktcode
andauthored
Throw error on subgraph when errors exist in response (#542)
* Throw error on subgraph when errors exist in response * 0.3.66 Co-authored-by: mkt <[email protected]>
1 parent c29e425 commit 0b75e03

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-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.3.65",
3+
"version": "0.3.66",
44
"repository": "snapshot-labs/snapshot.js",
55
"license": "MIT",
66
"main": "dist/snapshot.cjs.js",

src/utils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,15 @@ export async function subgraphRequest(url: string, query, options: any = {}) {
9494
},
9595
body: JSON.stringify({ query: jsonToGraphQLQuery({ query }) })
9696
});
97-
const { data } = await res.json();
97+
const responseData = await res.json();
98+
if (responseData.errors) {
99+
throw new Error(
100+
'Errors found in subgraphRequest: ' +
101+
url +
102+
JSON.stringify(responseData.errors)
103+
);
104+
}
105+
const { data } = responseData;
98106
return data || {};
99107
}
100108

0 commit comments

Comments
 (0)