Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for passing additional filters to EntityRequest #199

Merged
merged 3 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,25 @@
return this.build(context, arguments, entityScope, selectionSet);
}

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

Check warning on line 83 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#L81-L83

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

Check warning on line 87 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#L85-L87

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

Check warning on line 94 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#L89-L94

Added lines #L89 - L94 were not covered by tests
}

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

Check warning on line 181 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#L181

Added line #L181 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 {
aaron-steinfeld marked this conversation as resolved.
Show resolved Hide resolved
String entityType();

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

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(
EntityRequest originalRequest, List<FilterArgument> filterArguments);
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
context, timeRange, space, this.getOutgoingEdges(neighborFields)),
(resultSetRequest, metricRequestList, incomingEdges, outgoingEdges) ->
new NeighborEntityRequest(
context,
entityScope,
resultSetRequest,
metricRequestList,
Expand Down Expand Up @@ -174,6 +175,7 @@
@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