From 7c499c216e90d4212704c0720e74a6bde54c21ee Mon Sep 17 00:00:00 2001 From: Shiyas Mohammed <83513144+Shiyasmohd@users.noreply.github.com> Date: Tue, 3 Sep 2024 20:30:52 +0530 Subject: [PATCH] Return bytesAsIds,declaredEthCalls,aggreagtions,immutableEntities as features on status api (#5582) * graph,server: add more features on status api * fix: release build err * fix: test cases * refactor: add features from resolver fn --- graph/src/data/subgraph/features.rs | 10 +++++++++- server/index-node/src/resolver.rs | 19 ++++++++++++++++++- server/index-node/src/schema.graphql | 4 ++++ store/test-store/tests/postgres/subgraph.rs | 2 +- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/graph/src/data/subgraph/features.rs b/graph/src/data/subgraph/features.rs index da6b00d1ce6..dd2263858f9 100644 --- a/graph/src/data/subgraph/features.rs +++ b/graph/src/data/subgraph/features.rs @@ -33,6 +33,10 @@ pub enum SubgraphFeature { NonFatalErrors, Grafting, FullTextSearch, + Aggregations, + BytesAsIds, + DeclaredEthCalls, + ImmutableEntities, #[serde(alias = "nonDeterministicIpfs")] IpfsOnEthereumContracts, } @@ -154,11 +158,15 @@ mod tests { FullTextSearch, IpfsOnEthereumContracts, ]; - const STRING: [&str; 4] = [ + const STRING: [&str; 8] = [ "nonFatalErrors", "grafting", "fullTextSearch", "ipfsOnEthereumContracts", + "declaredEthCalls", + "aggregations", + "immutableEntities", + "bytesAsIds", ]; #[test] diff --git a/server/index-node/src/resolver.rs b/server/index-node/src/resolver.rs index 6ba26a5457e..fb3937afdc2 100644 --- a/server/index-node/src/resolver.rs +++ b/server/index-node/src/resolver.rs @@ -627,7 +627,24 @@ impl IndexNodeResolver { let subgraph_store = self.store.subgraph_store(); let features = match subgraph_store.subgraph_features(&deployment_hash).await? { - Some(features) => features, + Some(features) => { + let mut deployment_features = features.clone(); + let features = &mut deployment_features.features; + + if deployment_features.has_declared_calls { + features.push("declaredEthCalls".to_string()); + } + if deployment_features.has_aggregations { + features.push("aggregations".to_string()); + } + if !deployment_features.immutable_entities.is_empty() { + features.push("immutableEntities".to_string()); + } + if deployment_features.has_bytes_as_ids { + features.push("bytesAsIds".to_string()); + } + deployment_features + } None => self.get_features_from_ipfs(&deployment_hash).await?, }; diff --git a/server/index-node/src/schema.graphql b/server/index-node/src/schema.graphql index 26b5f61623f..4179cabad8c 100644 --- a/server/index-node/src/schema.graphql +++ b/server/index-node/src/schema.graphql @@ -161,6 +161,10 @@ enum Feature { grafting fullTextSearch ipfsOnEthereumContracts + aggregations + declaredEthCalls + immutableEntities + bytesAsIds } input BlockInput { diff --git a/store/test-store/tests/postgres/subgraph.rs b/store/test-store/tests/postgres/subgraph.rs index 0d0dda18920..f59519b8945 100644 --- a/store/test-store/tests/postgres/subgraph.rs +++ b/store/test-store/tests/postgres/subgraph.rs @@ -549,7 +549,7 @@ fn subgraph_features() { assert_eq!( vec![ SubgraphFeature::NonFatalErrors.to_string(), - SubgraphFeature::FullTextSearch.to_string() + SubgraphFeature::FullTextSearch.to_string(), ], features );