Skip to content

Commit 3722a76

Browse files
authored
refactor: only add aggregation in fragment if value is present (#789)
1 parent 35b7136 commit 3722a76

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

projects/distributed-tracing/src/public-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export {
7373
} from './shared/graphql/model/schema/metrics/graphql-metric-aggregation-type';
7474
export * from './shared/graphql/model/schema/sort/graphql-sort-argument';
7575
export * from './shared/graphql/model/schema/sort/graphql-sort-direction';
76+
export * from './shared/graphql/model/schema/sort/graphql-sort-without-direction';
7677
export * from './shared/graphql/model/schema/sort/graphql-sort-by-specification';
7778
export * from './shared/graphql/model/schema/timerange/graphql-time-range';
7879
export * from './shared/graphql/model/schema/specifier/specification';

projects/observability/src/shared/graphql/request/builders/specification/explore/explore-specification-builder.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { DateCoercer } from '@hypertrace/common';
1+
import { DateCoercer, Dictionary } from '@hypertrace/common';
22
import {
33
AttributeMetadataType,
44
convertToGraphQlMetricAggregationType,
55
GraphQlMetricAggregationType,
6+
GraphQlSortWithoutDirection,
67
MetricAggregationType
78
} from '@hypertrace/distributed-tracing';
89
import { GraphQlEnumArgument } from '@hypertrace/graphql-client';
@@ -47,10 +48,17 @@ export class ExploreSpecificationBuilder {
4748
children: [{ path: 'value' }, { path: 'type' }]
4849
}),
4950
extractFromServerData: serverData => serverData[queryAlias],
50-
asGraphQlOrderByFragment: () => ({
51-
key: key,
52-
aggregation: aggregation === undefined ? undefined : this.aggregationAsEnum(aggregation)
53-
})
51+
asGraphQlOrderByFragment: () => {
52+
const fragment: GraphQlSortWithoutDirection & Dictionary<unknown> = {
53+
key: key
54+
};
55+
56+
if (aggregation !== undefined) {
57+
fragment.aggregation = this.aggregationAsEnum(aggregation);
58+
}
59+
60+
return fragment;
61+
}
5462
};
5563
}
5664

0 commit comments

Comments
 (0)