I have a GraphQL query that pulls back all components and associated with a specific metric of interest and creates to lists:
- a list of components with value >0 sorted in desc order
- a list of components with no value for the metric ever
What I would love to do is add filters into the query itself to reduce the payload and need to post-process the results. My current query is:
query HallOfShame($after: String) {
compass {
metricDefinition(cloudId: "<CLOUD ID>", metricDefinitionId: "<METRIC ID>") {
... on CompassMetricDefinition {
name
metricSources(query:{first:50, after: $after}) {
... on CompassMetricSourcesConnection {
nodes {
values(query: {first:1}) {
... on CompassMetricSourceValuesConnection {
nodes {
value
timestamp
}
}
}
component {
name
state
typeId
url
links {
url
}
customFields {
... on CompassCustomBooleanField {
definition {
id
name
}
booleanValue
}
}
}
}
pageInfo { hasNextPage endCursor }
totalCount
}
}
}
}
}
}Now this works, but it pulls back a great deal of data I end up filtering out. For instance, I'm only interested in components with `typeId` of `SERVICE` and `status` of `ACTIVE`. Also I filter out any component with a customField named `excludeFromHOS` with a value of `true`.
Any insight into how I might add some of this to the query itself, or refactor the query to enable such filtering / sorting? I'm afraid as our usage of Compass grows this is going to become an issue with timeouts (already seeing them on occasion).