Skip to content

Commit

Permalink
refactor(graph-gateway): simplify subgraph deployments resolution (#563)
Browse files Browse the repository at this point in the history
  • Loading branch information
LNSD authored Jan 26, 2024
1 parent ad55cdf commit e7ec282
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 93 deletions.
81 changes: 45 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions gateway-framework/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ axum.workspace = true
ethers = "2.0.11"
eventuals = "0.6.7"
gateway-common = { path = "../gateway-common" }
graphql-http.workspace = true
headers = "0.3.9"
hex.workspace = true
indexer-selection = { path = "../indexer-selection" }
itertools = "0.12.0"
Expand All @@ -34,3 +36,6 @@ tokio.workspace = true
toolshed.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true

[dev-dependencies]
assert_matches = "1.5.0"
12 changes: 11 additions & 1 deletion gateway-framework/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use std::collections::BTreeMap;

use indexer_selection::UnresolvedBlock;
use axum::response::{IntoResponse, Response};
use itertools::Itertools;

use indexer_selection::UnresolvedBlock;

use crate::graphql;

#[derive(thiserror::Error, Debug)]
pub enum Error {
/// Errors that should only occur in exceptional conditions.
Expand Down Expand Up @@ -32,6 +36,12 @@ pub enum Error {
BadIndexers(IndexerErrors),
}

impl IntoResponse for Error {
fn into_response(self) -> Response {
graphql::error_response(self).into_response()
}
}

pub struct IndexerErrors(Vec<IndexerError>);

#[derive(thiserror::Error, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions gateway-framework/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub mod chains;
pub mod config;
pub mod errors;
pub mod geoip;
pub mod graphql;
pub mod ipfs;
pub mod json;
pub mod metrics;
Expand Down
Loading

0 comments on commit e7ec282

Please sign in to comment.