subgraph: Check supported spec version
For future-proofness.
@@ -620,7 +620,7 @@ pub struct BaseDataSource<M, T> {
pub name: String,
pub source: Source,
pub mapping: M,
- pub templates: Option<Vec<T>>,
+ pub templates: Option<Vec<T>>, // Deprecated in manifest spec version 0.0.2
}
pub type UnresolvedDataSource = BaseDataSource<UnresolvedMapping, UnresolvedDataSourceTemplate>;
@@ -903,7 +903,20 @@ impl UnresolvedSubgraphManifest {
templates,
} = self;
+ match semver::Version::parse(&spec_version) {
+ Ok(ref ver) if *ver <= semver::Version::new(0, 0, 2) => {}
+ _ => {
+ return Box::new(future::err(format_err!(
+ "This Graph Node only supports manifest spec versions <= 0.0.2,
+ but subgraph `{}` uses `{}`",
+ id,
+ spec_version
+ ))) as Box<dyn Future<Item = _, Error = _> + Send>;
+ }
+ }
+
// resolve each data set
+ Box::new(
schema
.resolve(id.clone(), resolver, logger.clone())
.join(
@@ -931,6 +944,7 @@ impl UnresolvedSubgraphManifest {
schema,
data_sources,
templates,
- })
+ }),
+ )
}
}
