Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
Implement spec-compliant error responses
Browse files Browse the repository at this point in the history
  • Loading branch information
deekerno committed Dec 13, 2023
1 parent 3a380b9 commit 829fa86
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/fuel-indexer-api-server/src/uses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,25 @@ pub(crate) async fn query_graph(
let dynamic_schema =
fuel_indexer_graphql::dynamic::build_dynamic_schema(&schema)?;
let user_query = req.0.query.clone();
let response = fuel_indexer_graphql::query::execute(
match fuel_indexer_graphql::query::execute(
req.into_inner(),
dynamic_schema,
user_query,
pool,
schema,
)
.await?;
let data = serde_json::json!({ "data": response });
Ok(axum::Json(data))
.await
{
Ok(response) => {
let data = serde_json::json!({"data": response});
Ok(axum::Json(data))
}
Err(e) => {
let data =
serde_json::json!({"errors": [{"message": e.to_string()}]});
Ok(axum::Json(data))
}
}
}
Err(_e) => Err(ApiError::Http(HttpError::NotFound(format!(
"The graph '{namespace}.{identifier}' was not found."
Expand Down

0 comments on commit 829fa86

Please sign in to comment.