From d23ae524c2aad8f8c70e1e6cd2d3493c9db0a340 Mon Sep 17 00:00:00 2001 From: Gustavo Inacio Date: Wed, 30 Oct 2024 11:31:18 -0600 Subject: [PATCH] fix: add more information about failing subgraph query Signed-off-by: Gustavo Inacio --- common/src/subgraph_client/client.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/common/src/subgraph_client/client.rs b/common/src/subgraph_client/client.rs index 8dc52c3e..65ecb9e1 100644 --- a/common/src/subgraph_client/client.rs +++ b/common/src/subgraph_client/client.rs @@ -184,8 +184,15 @@ impl DeploymentClient { // TODO handle partial responses Ok(match (response.data, response.errors) { (Some(data), None) => Ok(data), - (_, Some(errors)) => Err(anyhow!("{errors:?}")), - (_, _) => Err(anyhow!("Invalid error")), + (None, Some(errors)) => Err(anyhow!("{errors:?}")), + (Some(_data), Some(err)) => Err(anyhow!("Unsupported partial results. Error: {err:?}")), + (None, None) => { + let body = serde_json::to_string(&body).unwrap_or_default(); + Err(anyhow!( + "No data or error returned for query: {body}. Endpoint: {}", + self.query_url.as_str() + )) + } }) }