-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix type change and directive deletion problems in schema diffing #3102
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
| 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)) { |
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.
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)) { |
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.
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 |
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 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=")); |
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.
Is "type=" strings a good idea here?
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.
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
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.
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.
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.
Good point
| } | ||
| String newType = getTypeFromEdgeLabel(editOperation.getTargetEdge()); | ||
| EditOperation deletedTypeEdgeOperation = findDeletedEdge(inputField, editOperations, mapping); | ||
| EditOperation deletedTypeEdgeOperation = findDeletedEdge(inputField, editOperations, mapping, edge -> edge.getLabel().contains("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.
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.
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.
Either way, it works now.