-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Check for default value changes #3157
Merged
dondonz
merged 1 commit into
graphql-java:master
from
gnawf:check-for-default-value-changes
Mar 31, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -960,8 +960,9 @@ private void typeEdgeInserted(EditOperation editOperation, List<EditOperation> e | |
|
||
} | ||
|
||
private void typeEdgeInsertedForInputField(EditOperation | ||
editOperation, List<EditOperation> editOperations, Mapping mapping) { | ||
private void typeEdgeInsertedForInputField(EditOperation editOperation, | ||
List<EditOperation> editOperations, | ||
Mapping mapping) { | ||
Vertex inputField = editOperation.getTargetEdge().getFrom(); | ||
Vertex inputObject = newSchemaGraph.getInputObjectForInputField(inputField); | ||
if (isInputObjectAdded(inputObject.getName())) { | ||
|
@@ -977,8 +978,9 @@ private void typeEdgeInsertedForInputField(EditOperation | |
getInputObjectModification(inputObject.getName()).getDetails().add(inputObjectFieldTypeModification); | ||
} | ||
|
||
private void typeEdgeInsertedForArgument(EditOperation | ||
editOperation, List<EditOperation> editOperations, Mapping mapping) { | ||
private void typeEdgeInsertedForArgument(EditOperation editOperation, | ||
List<EditOperation> editOperations, | ||
Mapping mapping) { | ||
Vertex argument = editOperation.getTargetEdge().getFrom(); | ||
Vertex fieldOrDirective = newSchemaGraph.getFieldOrDirectiveForArgument(argument); | ||
if (fieldOrDirective.isOfType(SchemaGraph.FIELD)) { | ||
|
@@ -987,6 +989,7 @@ private void typeEdgeInsertedForArgument(EditOperation | |
|
||
if (objectOrInterface.isOfType(SchemaGraph.OBJECT)) { | ||
Vertex object = objectOrInterface; | ||
|
||
// if the whole object is new we are done | ||
if (isObjectAdded(object.getName())) { | ||
return; | ||
|
@@ -999,16 +1002,24 @@ private void typeEdgeInsertedForArgument(EditOperation | |
if (isArgumentNewForExistingObjectField(object.getName(), field.getName(), argument.getName())) { | ||
return; | ||
} | ||
|
||
String newType = getTypeFromEdgeLabel(editOperation.getTargetEdge()); | ||
// this means we have an existing object changed its type | ||
// and there must be a deleted edge with the old type information | ||
EditOperation deletedTypeEdgeOperation = findDeletedEdge(argument, editOperations, mapping, this::isTypeEdge); | ||
String oldType = getTypeFromEdgeLabel(deletedTypeEdgeOperation.getSourceEdge()); | ||
ObjectFieldArgumentTypeModification objectFieldArgumentTypeModification = new ObjectFieldArgumentTypeModification(field.getName(), argument.getName(), oldType, newType); | ||
getObjectModification(object.getName()).getDetails().add(objectFieldArgumentTypeModification); | ||
|
||
String oldDefaultValue = getDefaultValueFromEdgeLabel(deletedTypeEdgeOperation.getSourceEdge()); | ||
String newDefaultValue = getDefaultValueFromEdgeLabel(editOperation.getTargetEdge()); | ||
if (!oldDefaultValue.equals(newDefaultValue)) { | ||
getObjectModification(object.getName()).getDetails().add(new ObjectFieldArgumentDefaultValueModification(field.getName(), argument.getName(), oldDefaultValue, newDefaultValue)); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added this, which was missing. It's done in some other cases. |
||
} else { | ||
assertTrue(objectOrInterface.isOfType(SchemaGraph.INTERFACE)); | ||
Vertex interfaze = objectOrInterface; | ||
|
||
// if the whole object is new we are done | ||
if (isInterfaceAdded(interfaze.getName())) { | ||
return; | ||
|
@@ -1021,34 +1032,49 @@ private void typeEdgeInsertedForArgument(EditOperation | |
if (isArgumentNewForExistingInterfaceField(interfaze.getName(), field.getName(), argument.getName())) { | ||
return; | ||
} | ||
|
||
String newType = getTypeFromEdgeLabel(editOperation.getTargetEdge()); | ||
// this means we have an existing object changed its type | ||
// and there must be a deleted edge with the old type information | ||
EditOperation deletedTypeEdgeOperation = findDeletedEdge(argument, editOperations, mapping, this::isTypeEdge); | ||
String oldType = getTypeFromEdgeLabel(deletedTypeEdgeOperation.getSourceEdge()); | ||
InterfaceFieldArgumentTypeModification interfaceFieldArgumentTypeModification = new InterfaceFieldArgumentTypeModification(field.getName(), argument.getName(), oldType, newType); | ||
getInterfaceModification(interfaze.getName()).getDetails().add(interfaceFieldArgumentTypeModification); | ||
|
||
String oldDefaultValue = getDefaultValueFromEdgeLabel(deletedTypeEdgeOperation.getSourceEdge()); | ||
String newDefaultValue = getDefaultValueFromEdgeLabel(editOperation.getTargetEdge()); | ||
if (!oldDefaultValue.equals(newDefaultValue)) { | ||
getInterfaceModification(interfaze.getName()).getDetails().add(new InterfaceFieldArgumentDefaultValueModification(field.getName(), argument.getName(), oldDefaultValue, newDefaultValue)); | ||
} | ||
} | ||
} else { | ||
assertTrue(fieldOrDirective.isOfType(SchemaGraph.DIRECTIVE)); | ||
Vertex directive = fieldOrDirective; | ||
|
||
if (isDirectiveAdded(directive.getName())) { | ||
return; | ||
} | ||
if (isArgumentNewForExistingDirective(directive.getName(), argument.getName())) { | ||
return; | ||
} | ||
|
||
String newType = getTypeFromEdgeLabel(editOperation.getTargetEdge()); | ||
EditOperation deletedTypeEdgeOperation = findDeletedEdge(argument, editOperations, mapping, this::isTypeEdge); | ||
String oldType = getTypeFromEdgeLabel(deletedTypeEdgeOperation.getSourceEdge()); | ||
DirectiveArgumentTypeModification directiveArgumentTypeModification = new DirectiveArgumentTypeModification(argument.getName(), oldType, newType); | ||
getDirectiveModification(directive.getName()).getDetails().add(directiveArgumentTypeModification); | ||
} | ||
|
||
String oldDefaultValue = getDefaultValueFromEdgeLabel(deletedTypeEdgeOperation.getSourceEdge()); | ||
String newDefaultValue = getDefaultValueFromEdgeLabel(editOperation.getTargetEdge()); | ||
if (!oldDefaultValue.equals(newDefaultValue)) { | ||
getDirectiveModification(directive.getName()).getDetails().add(new DirectiveArgumentDefaultValueModification(argument.getName(), oldDefaultValue, newDefaultValue)); | ||
} | ||
} | ||
} | ||
|
||
private void typeEdgeInsertedForField(EditOperation | ||
editOperation, List<EditOperation> editOperations, Mapping mapping) { | ||
private void typeEdgeInsertedForField(EditOperation editOperation, | ||
List<EditOperation> editOperations, | ||
Mapping mapping) { | ||
Vertex field = editOperation.getTargetEdge().getFrom(); | ||
Vertex objectOrInterface = newSchemaGraph.getFieldsContainerForField(field); | ||
if (objectOrInterface.isOfType(SchemaGraph.OBJECT)) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just reformat