Skip to content

Commit

Permalink
Return bytesAsIds,declaredEthCalls,aggreagtions,immutableEntities as …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
shiyasmohd authored Sep 3, 2024
1 parent 60a3c14 commit 7c499c2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
10 changes: 9 additions & 1 deletion graph/src/data/subgraph/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ pub enum SubgraphFeature {
NonFatalErrors,
Grafting,
FullTextSearch,
Aggregations,
BytesAsIds,
DeclaredEthCalls,
ImmutableEntities,
#[serde(alias = "nonDeterministicIpfs")]
IpfsOnEthereumContracts,
}
Expand Down Expand Up @@ -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]
Expand Down
19 changes: 18 additions & 1 deletion server/index-node/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,24 @@ impl<S: Store> IndexNodeResolver<S> {

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?,
};

Expand Down
4 changes: 4 additions & 0 deletions server/index-node/src/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ enum Feature {
grafting
fullTextSearch
ipfsOnEthereumContracts
aggregations
declaredEthCalls
immutableEntities
bytesAsIds
}

input BlockInput {
Expand Down
2 changes: 1 addition & 1 deletion store/test-store/tests/postgres/subgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ fn subgraph_features() {
assert_eq!(
vec![
SubgraphFeature::NonFatalErrors.to_string(),
SubgraphFeature::FullTextSearch.to_string()
SubgraphFeature::FullTextSearch.to_string(),
],
features
);
Expand Down

0 comments on commit 7c499c2

Please sign in to comment.