-
Notifications
You must be signed in to change notification settings - Fork 7
chore | adding the support of edge filters in edges #167
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #167 +/- ##
============================================
- Coverage 22.84% 22.36% -0.49%
Complexity 75 75
============================================
Files 65 68 +3
Lines 1742 1784 +42
Branches 53 54 +1
============================================
+ Hits 398 399 +1
- Misses 1335 1376 +41
Partials 9 9
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming this was not ready to review yet. Please mark it as draft in that case and re-request review when ready.
...l-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayServiceEntityDao.java
Outdated
Show resolved
Hide resolved
TimeRangeArgument timeRange, | ||
Optional<String> space, | ||
Map<String, Set<SelectedField>> edgesByType, | ||
Stream<SelectedField> edgeSetFields, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks to be off. There are potentially multiple edge requests that each can have different fields and filters - hence the previous map of type to fields. We're splitting them up later here, but we're not doing the same thing for filters.
...ql-entity-schema/src/main/java/org/hypertrace/graphql/entity/request/EdgeRequestBuilder.java
Outdated
Show resolved
Hide resolved
...ql-entity-schema/src/main/java/org/hypertrace/graphql/entity/request/EdgeRequestBuilder.java
Outdated
Show resolved
Hide resolved
|
||
private List<FilterArgument> getFilters(Set<SelectedField> selectedFields) { | ||
return selectedFields.stream() | ||
.map( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
referred to in other comment, but this is combining the filter arguments from each independent edge request (each field here is one edge request like incomingEdges(type: X)
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This I have already discussed with @skjindal93 . With this PR we are adding two limitations in the case of using edge filters,
- If using edge filters, we can only have one entityType incoming/outgoing edge
- In the case of different filters for each selected field. They will be merged into one AND filter.
we are introducing this to solve the deliverable first. Immediately after this we will make the changes to remove above two limitations. Currently, no one is using multiple entity types interactions, so it won't break anything. also old behaviour is still intact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason we didnt solve this is because it will need big change in gateway service where we will have to make interactions request as an array of request rather than one single filter which it is right now. https://github.com/hypertrace/gateway-service/blob/main/gateway-service-api/src/main/proto/org/hypertrace/gateway/service/v1/entities.proto#L41 this is the filter i am referring to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I agree here, but we can discuss further.
Currently, no one is using multiple entity types interactions, so it won't break anything
Confused here - the main application flow uses multiple entity types? It shows services with downstream services and downstream backends.
The reason we didnt solve this is because it will need big change in gateway service where we will have to make interactions request as an array of request rather than one single filter which it is right now.
We already handle multiple entity types through a filter, is this different? You'd need to just change how you build the filter to OR across selection types and then AND for each selection type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confused here - the main application flow uses multiple entity types? It shows services with downstream services and downstream backends.
It won't break the current workflows. Those api will work. These limitations only come into the picture when filters are being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to leave an api in this broken state though - so if this is going to impact how we implement things, we should be considering that now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were just planning to do it in iterations. Have a basic application flow working with limitations (not breaking the existing application flow), and then refactor it next to make it perfect. (because, refactoring would take considerable amount of time otherwise, causing delays for Third Party APIs)
We are definitely planning to pick up the refactor as the next task
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't require a big refactor though - that's the part that's confusing me. The refactor would just be in the new code that's being written in these 2 PRs, right? I can definitely be mistaken, but aren't we talking a handful of lines (since we already have the infrastructure to separate out the requests then merge them for the existing code)?
If we choose not to however, can we at least have this error out if we receive an unsupported request? My bigger concern is that certain calls will just result in success but have inaccurate results (because filters get merged that shouldn't be).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already handle multiple entity types through a filter, is this different? You'd need to just change how you build the filter to OR across selection types and then AND for each selection type.
This won't work actually if I am understanding it correctly. Consider this for an example, let's say we query for two edges like this
incomingEdge (scope: SERVICE, filter: {dataType in "dataTypeIds1"})
incomingEdge (scope: API, filter: {dataType in "dataTypeIds2"} }
Now the interaction request to the gateway service will be like this
filter AND [
{ fromEntityType in SERVICE, API}
{ dataType in dataTypeIds1 } OR { dataType in dataTypeIds2 }
]
Now this will return wrong results for both service and api. Since each filter corresponding to the edge is specific to that interaction we cannot do it in a single query. We will need to change the API contract and make gateway service to run each edge query separately. For now, we have made the code error out in case of above-mentioned limitations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now this will return wrong results for both service and api. Since each filter corresponding to the edge is specific to that interaction we cannot do it in a single query
I was actually suggesting:
filter OR [
{{ fromEntityType = SERVICE} AND { dataType in dataTypeIds1 }}
{{ fromEntityType = API} AND { dataType in dataTypeIds2 }}
]
Would that be problematic?
I don't think i can convert the PR in draft state now. I have added WIP marker on top. Will ask for review once i am done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
...ql-entity-schema/src/main/java/org/hypertrace/graphql/entity/request/EdgeRequestBuilder.java
Outdated
Show resolved
Hide resolved
...-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/OutgoingEdgesDataFetcher.java
Outdated
Show resolved
Hide resolved
...-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/OutgoingEdgesDataFetcher.java
Outdated
Show resolved
Hide resolved
...-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/IncomingEdgesDataFetcher.java
Show resolved
Hide resolved
Co-authored-by: sanket-mundra <[email protected]>
No description provided.