Skip to content

Commit

Permalink
Added support for passing additional filters to EntityRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
avinashkolluru committed Oct 5, 2023
1 parent a98a91c commit 5cc2ac0
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ private Single<EntityRequest> buildEntityRequest(
context, entityType, this.entityFieldsByType.get(entityType)),
(resultSetRequest, metricRequestList, optionalLabelRequest) ->
new DefaultEntityRequest(
entityType, resultSetRequest, metricRequestList, optionalLabelRequest));
context, entityType, resultSetRequest, metricRequestList, optionalLabelRequest));
}

private Single<List<AttributeAssociation<FilterArgument>>> buildIdFilter(
Expand All @@ -304,6 +304,7 @@ private Single<List<AttributeAssociation<FilterArgument>>> buildIdFilter(
@Value
@Accessors(fluent = true)
private static class DefaultEntityRequest implements EntityRequest {
GraphQlRequestContext context;
String entityType;
ResultSetRequest<AggregatableOrderArgument> resultSetRequest;
List<MetricRequest> metricRequests;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.hypertrace.core.graphql.common.request.ResultSetRequestBuilder;
import org.hypertrace.core.graphql.common.schema.arguments.TimeRangeArgument;
import org.hypertrace.core.graphql.common.schema.results.ResultSet;
import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument;
import org.hypertrace.core.graphql.common.schema.results.arguments.space.SpaceArgument;
import org.hypertrace.core.graphql.context.GraphQlRequestContext;
import org.hypertrace.core.graphql.deserialization.ArgumentDeserializer;
Expand Down Expand Up @@ -74,6 +75,27 @@ public Single<EntityRequest> build(
return this.build(context, arguments, entityScope, selectionSet);
}

@Override
public Single<EntityRequest> rebuildWithAdditionalFilters(
GraphQlRequestContext context,
EntityRequest originalRequest,
List<FilterArgument> filterArguments) {
return this.resultSetRequestBuilder
.rebuildWithAdditionalFilters(originalRequest.resultSetRequest(), filterArguments)
.map(

Check warning on line 85 in hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/request/DefaultEntityRequestBuilder.java

View check run for this annotation

Codecov / codecov/patch

hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/request/DefaultEntityRequestBuilder.java#L83-L85

Added lines #L83 - L85 were not covered by tests
newResultSetRequest ->
new DefaultEntityRequest(
originalRequest.context(),
originalRequest.entityType(),

Check warning on line 89 in hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/request/DefaultEntityRequestBuilder.java

View check run for this annotation

Codecov / codecov/patch

hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/request/DefaultEntityRequestBuilder.java#L87-L89

Added lines #L87 - L89 were not covered by tests
newResultSetRequest,
originalRequest.metricRequests(),
originalRequest.incomingEdgeRequests(),
originalRequest.outgoingEdgeRequests(),
originalRequest.includeInactive(),
originalRequest.fetchTotal(),
originalRequest.labelRequest()));

Check warning on line 96 in hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/request/DefaultEntityRequestBuilder.java

View check run for this annotation

Codecov / codecov/patch

hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/request/DefaultEntityRequestBuilder.java#L91-L96

Added lines #L91 - L96 were not covered by tests
}

private Single<EntityRequest> build(
GraphQlRequestContext context,
Map<String, Object> arguments,
Expand Down Expand Up @@ -113,6 +135,7 @@ private Single<EntityRequest> build(
outgoingEdges,
optionalLabelsAttributeRequest) ->
new DefaultEntityRequest(
context,
scope,
resultSetRequest,
metricRequestList,
Expand Down Expand Up @@ -157,6 +180,7 @@ private Optional<String> space(Map<String, Object> arguments) {
@Value
@Accessors(fluent = true)
private static class DefaultEntityRequest implements EntityRequest {
GraphQlRequestContext context;

Check warning on line 183 in hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/request/DefaultEntityRequestBuilder.java

View check run for this annotation

Codecov / codecov/patch

hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/request/DefaultEntityRequestBuilder.java#L183

Added line #L183 was not covered by tests
String entityType;
ResultSetRequest<AggregatableOrderArgument> resultSetRequest;
List<MetricRequest> metricRequests;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import java.util.List;
import java.util.Optional;
import org.hypertrace.core.graphql.common.request.ContextualRequest;
import org.hypertrace.core.graphql.common.request.ResultSetRequest;
import org.hypertrace.graphql.metric.request.MetricRequest;
import org.hypertrace.graphql.metric.schema.argument.AggregatableOrderArgument;

public interface EntityRequest {
public interface EntityRequest extends ContextualRequest {
String entityType();

ResultSetRequest<AggregatableOrderArgument> resultSetRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@

import graphql.schema.DataFetchingFieldSelectionSet;
import io.reactivex.rxjava3.core.Single;
import java.util.List;
import java.util.Map;
import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument;
import org.hypertrace.core.graphql.context.GraphQlRequestContext;

public interface EntityRequestBuilder {
Single<EntityRequest> build(
GraphQlRequestContext context,
Map<String, Object> arguments,
DataFetchingFieldSelectionSet selectionSet);

Single<EntityRequest> rebuildWithAdditionalFilters(
GraphQlRequestContext context,
EntityRequest originalRequest,
List<FilterArgument> filterArguments);
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ private Single<EntityRequest> build(
context, timeRange, space, this.getOutgoingEdges(neighborFields)),
(resultSetRequest, metricRequestList, incomingEdges, outgoingEdges) ->
new NeighborEntityRequest(
context,
entityScope,
resultSetRequest,
metricRequestList,
Expand Down Expand Up @@ -174,6 +175,7 @@ private static class EntityNeighborIdFilter implements FilterArgument {
@Value
@Accessors(fluent = true)
private static class NeighborEntityRequest implements EntityRequest {
GraphQlRequestContext context;

Check warning on line 178 in hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/request/NeighborEntitiesRequestBuilder.java

View check run for this annotation

Codecov / codecov/patch

hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/request/NeighborEntitiesRequestBuilder.java#L178

Added line #L178 was not covered by tests
String entityType;
ResultSetRequest<AggregatableOrderArgument> resultSetRequest;
List<MetricRequest> metricRequests;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ private Single<EntityRequest> buildEntityRequest(
filterArguments,
selectionSet.getFields().stream(),
Optional.empty())
.map(request -> new DefaultEntityRequest(entityType, request, fetchTotal));
.map(request -> new DefaultEntityRequest(context, entityType, request, fetchTotal));
}

private Single<List<AttributeAssociation<FilterArgument>>> buildLabelIdFilter(
Expand All @@ -303,6 +303,7 @@ private Single<List<AttributeAssociation<FilterArgument>>> buildLabelIdFilter(
@Value
@Accessors(fluent = true)
private static class DefaultEntityRequest implements EntityRequest {
GraphQlRequestContext context;
String entityType;
ResultSetRequest<AggregatableOrderArgument> resultSetRequest;
List<MetricRequest> metricRequests = Collections.emptyList(); // Only support attributes for now
Expand Down

0 comments on commit 5cc2ac0

Please sign in to comment.