Skip to content

Conversation

@gnawf
Copy link
Contributor

@gnawf gnawf commented Mar 1, 2023

I think at some point the Edges to retain more information from the original schema e.g. relationship information. Ideally not in a String.

It's possible that future changes to the GraphQL spec could change the schema. A lot of this code relies on implicit assumptions that could be broken.

e.g. instead of saying I want to only look at union members, I have to assume that there are only union members and applied directives. Then ignore the applied directives.

oldEdge.getFrom().isOfType(SchemaGraph.UNION) && !oldEdge.getTo().isOfType(SchemaGraph.APPLIED_DIRECTIVE)

Either way, it works now.

case DELETE_EDGE:
Edge oldEdge = editOperation.getSourceEdge();
if (oldEdge.getFrom().isOfType(SchemaGraph.UNION)) {
if (oldEdge.getFrom().isOfType(SchemaGraph.UNION) && !oldEdge.getTo().isOfType(SchemaGraph.APPLIED_DIRECTIVE)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes a bug where deleted directives were considered deleted union members.

case DELETE_EDGE:
Edge oldEdge = editOperation.getSourceEdge();
if (oldEdge.getFrom().isOfType(SchemaGraph.ENUM)) {
if (oldEdge.getFrom().isOfType(SchemaGraph.ENUM) && oldEdge.getTo().isOfType(SchemaGraph.ENUM_VALUE)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes a bug where deleted directives were considered deleted enum values.

def appliedDirective = (changes.enumDifferences["E"] as EnumModification).getDetails(AppliedDirectiveDeletion)
def diff = changes.enumDifferences["E"] as EnumModification

diff.getDetails().size() == 1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't had time to change the rest, but the tests should really ensure all details are checked.

In this test we previously had an undetected change where the deleted directive also introduced a enum value removed change detail.

}
String newType = getTypeFromEdgeLabel(editOperation.getTargetEdge());
EditOperation deletedTypeEdgeOperation = findDeletedEdge(inputField, editOperations, mapping);
EditOperation deletedTypeEdgeOperation = findDeletedEdge(inputField, editOperations, mapping, edge -> edge.getLabel().contains("type="));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "type=" strings a good idea here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I reckon a better solution is to store a relationship enum that tracks how the two vertices were related to each other.

Andi suggested this is fine for now. Or did I misunderstand in our meeting? @andimarek

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the edge having type= as indicator that this is an "type edge" is ok for now.

But: can we make this is bit more dry and contain this logic a bit?

We have already getDefaultValueFromEdgeLabel helper method. I would recommend to add another helper method like "isTypeEdge" and use that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point

@gnawf gnawf mentioned this pull request Mar 1, 2023
}
String newType = getTypeFromEdgeLabel(editOperation.getTargetEdge());
EditOperation deletedTypeEdgeOperation = findDeletedEdge(inputField, editOperations, mapping);
EditOperation deletedTypeEdgeOperation = findDeletedEdge(inputField, editOperations, mapping, edge -> edge.getLabel().contains("type="));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the edge having type= as indicator that this is an "type edge" is ok for now.

But: can we make this is bit more dry and contain this logic a bit?

We have already getDefaultValueFromEdgeLabel helper method. I would recommend to add another helper method like "isTypeEdge" and use that.

@andimarek andimarek added this pull request to the merge queue Mar 1, 2023
Merged via the queue into graphql-java:master with commit 4580388 Mar 1, 2023
@dondonz dondonz added this to the 2023 April milestone Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants