Skip to content

Commit

Permalink
graph: restrict substreams subgraph with more than 1 datasource
Browse files Browse the repository at this point in the history
  • Loading branch information
incrypto32 committed Jun 26, 2024
1 parent 375bf80 commit 1c6ff19
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions graph/src/data/subgraph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ use std::sync::Arc;

use super::{graphql::IntoValue, value::Word};

pub const SUBSTREAMS_KIND: &str = "substreams";

/// Deserialize an Address (with or without '0x' prefix).
fn deserialize_address<'de, D>(deserializer: D) -> Result<Option<Address>, D::Error>
where
Expand Down Expand Up @@ -961,6 +963,14 @@ impl<C: Blockchain> UnresolvedSubgraphManifest<C> {
)
.await?;

let is_substreams = data_sources.iter().any(|ds| ds.kind() == SUBSTREAMS_KIND);
if is_substreams && ds_count > 1 {
return Err(anyhow!(
"A Substreams-based subgraph can only contain a single data source."
)
.into());
}

for ds in &data_sources {
ensure!(
semver::VersionReq::parse(&format!("<= {}", ENV_VARS.mappings.max_api_version))
Expand Down

0 comments on commit 1c6ff19

Please sign in to comment.