mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 18:20:30 +08:00
Add retries to querySubgraph fn
Signed-off-by: Sebastian Martinez <sebastinez@me.com> Reviewed-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
+3
-1
@@ -155,6 +155,7 @@ export async function querySubgraph(
|
||||
url: string,
|
||||
query: string,
|
||||
variables: Record<string, any>,
|
||||
retries = 3
|
||||
): Promise<null | any> {
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
@@ -172,7 +173,8 @@ export async function querySubgraph(
|
||||
for (const e of json.errors) {
|
||||
console.error("querySubgraph:", e.message);
|
||||
}
|
||||
return null;
|
||||
if (retries > 0) querySubgraph(url, query, variables, retries - 1);
|
||||
else return null;
|
||||
}
|
||||
|
||||
return json.data;
|
||||
|
||||
Reference in New Issue
Block a user