You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ke...@apache.org on 2021/05/19 14:09:20 UTC
[skywalking] 01/01: Fetch further data only when they're requested
This is an automated email from the ASF dual-hosted git repository.
kezhenxu94 pushed a commit to branch enhancement/query
in repository https://gitbox.apache.org/repos/asf/skywalking.git
commit d3948536cfcf0311b10fc852bc329fd1242cf33d
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Wed May 19 22:08:50 2021 +0800
Fetch further data only when they're requested
---
.../skywalking/oap/query/graphql/resolver/AlarmQuery.java | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/AlarmQuery.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/AlarmQuery.java
index c0d38f4..8256ade 100644
--- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/AlarmQuery.java
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/AlarmQuery.java
@@ -20,6 +20,7 @@ package org.apache.skywalking.oap.query.graphql.resolver;
import com.coxautodev.graphql.tools.GraphQLQueryResolver;
+import graphql.schema.DataFetchingEnvironment;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -79,7 +80,8 @@ public class AlarmQuery implements GraphQLQueryResolver {
}
public Alarms getAlarm(final Duration duration, final Scope scope, final String keyword,
- final Pagination paging, final List<Tag> tags) throws Exception {
+ final Pagination paging, final List<Tag> tags,
+ final DataFetchingEnvironment env) throws Exception {
Integer scopeId = null;
if (scope != null) {
scopeId = scope.getScopeId();
@@ -94,7 +96,14 @@ public class AlarmQuery implements GraphQLQueryResolver {
}
Alarms alarms = getQueryService().getAlarm(
scopeId, keyword, paging, startSecondTB, endSecondTB, tags);
- return findRelevantEvents(alarms, conditionPrototype);
+
+ final boolean selectEvents = env.getSelectionSet().get().containsKey("items/events");
+
+ if (selectEvents) {
+ return findRelevantEvents(alarms, conditionPrototype);
+ }
+
+ return alarms;
}
private Alarms findRelevantEvents(