X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -1723,19 +1723,26 @@ private void argumentAdded(EditOperation editOperation) {
Vertex fieldsContainerForField = newSchemaGraph.getFieldsContainerForField(field);
if (fieldsContainerForField.isOfType(SchemaGraph.OBJECT)) {
Vertex object = fieldsContainerForField;
if (isObjectAdded(object.getName())) {
return;
}
getObjectModification(object.getName()).getDetails().add(new ObjectFieldArgumentAddition(field.getName(), addedArgument.getName()));
} else {
assertTrue(fieldsContainerForField.isOfType(SchemaGraph.INTERFACE));
Vertex interfaze = fieldsContainerForField;
if (isInterfaceAdded(interfaze.getName())) {
return;
}
getInterfaceModification(interfaze.getName()).getDetails().add(new InterfaceFieldArgumentAddition(field.getName(), addedArgument.getName()));
}
} else {
assertTrue(fieldOrDirective.isOfType(SchemaGraph.DIRECTIVE));
Vertex directive = fieldOrDirective;
if (isDirectiveAdded(directive.getName())) {
return;
}
getDirectiveModification(directive.getName()).getDetails().add(new DirectiveArgumentAddition(addedArgument.getName()));

}

}

private void changedEnum(EditOperation editOperation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2035,6 +2035,94 @@ class EditOperationAnalyzerTest extends Specification {
changes.objectDifferences["Node"] instanceof ObjectDeletion
}

def "directive deleted with argument"() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This matches the other two tests above, I forgot to add one for directives.

given:
def oldSdl = '''
type Query {
node: String
}
directive @test(message: String) on FIELD
'''
def newSdl = '''
type Query {
node: String
}
'''

when:
def changes = calcDiff(oldSdl, newSdl)

then:
changes.directiveDifferences["test"] instanceof DirectiveDeletion
}

def "interface added with field argument"() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are duplicates of the directive deleted tests, but with the old and new schema swapped and the check asserts there's a XAddition difference in the result.

given:
def oldSdl = '''
type Query {
node: ID
}
'''
def newSdl = '''
type Query {
node: Node
}
interface Node {
echo(test: String): String
}
'''

when:
def changes = calcDiff(oldSdl, newSdl)

then:
changes.interfaceDifferences["Node"] instanceof InterfaceAddition
}

def "object added with field argument"() {
given:
def oldSdl = '''
type Query {
node: ID
}
'''
def newSdl = '''
type Query {
node: Node
}
type Node {
echo(test: String): String
}
'''

when:
def changes = calcDiff(oldSdl, newSdl)

then:
changes.objectDifferences["Node"] instanceof ObjectAddition
}

def "directive added with argument"() {
given:
def oldSdl = '''
type Query {
node: String
}
'''
def newSdl = '''
type Query {
node: String
}
directive @test(message: String) on FIELD
'''

when:
def changes = calcDiff(oldSdl, newSdl)

then:
changes.directiveDifferences["test"] instanceof DirectiveAddition
}

EditOperationAnalysisResult calcDiff(
String oldSdl,
String newSdl
Expand Down
X Tutup