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
24 changes: 13 additions & 11 deletions src/main/java/graphql/schema/diffing/DiffImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,19 +400,21 @@ private double calcLowerBoundMappingCost(Vertex v,
Map<Vertex, Double> isolatedVerticesCache,
Map<Vertex, Vertex> nonFixedParentRestrictions) {
if (nonFixedParentRestrictions.containsKey(v) || partialMapping.hasParentRestriction(v)) {
Vertex uParentRestriction = nonFixedParentRestrictions.get(v);
if (uParentRestriction == null) {
uParentRestriction = partialMapping.getParentRestriction(v);
}
if (!u.isIsolated()) { // Always allow mapping to isolated nodes
Vertex uParentRestriction = nonFixedParentRestrictions.get(v);
if (uParentRestriction == null) {
uParentRestriction = partialMapping.getParentRestriction(v);
}

Collection<Edge> parentEdges = completeTargetGraph.getAdjacentEdgesInverseNonCopy(u);
if (parentEdges.size() != 1) {
return Integer.MAX_VALUE;
}
Collection<Edge> parentEdges = completeTargetGraph.getAdjacentEdgesInverseNonCopy(u);
if (parentEdges.size() != 1) {
return Integer.MAX_VALUE;
}

Vertex uParent = parentEdges.iterator().next().getFrom();
if (uParent != uParentRestriction) {
return Integer.MAX_VALUE;
Vertex uParent = parentEdges.iterator().next().getFrom();
if (uParent != uParentRestriction) {
return Integer.MAX_VALUE;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3044,6 +3044,111 @@ class EditOperationAnalyzerTest extends Specification {
userModification.details.isEmpty()
}

def "deleted field with fixed parent binding can map to isolated node"() {
given:
def oldSdl = '''
type Query {
notifications: NotificationQuery
}
type NotificationQuery {
notificationFeed(
feedFilter: NotificationFeedFilter
first: Int = 25
after: String
): NotificationGroupedConnection!
unseenNotificationCount(workspaceId: String, product: String): Int!
}
input NotificationFeedFilter {
workspaceId: String
productFilter: String
groupId: String
}
type NotificationItem {
notificationId: ID!
workspaceId: String
}
type NotificationGroupedItem {
groupId: ID!
groupSize: Int!
headNotification: NotificationItem!
childItems(first: Int, after: String): [NotificationItem!]
}
type NotificationGroupedConnection {
nodes: [NotificationGroupedItem!]!
}
'''
def newSdl = '''
type Query {
notifications: NotificationQuery
}
type NotificationQuery {
notificationFeed(
filter: NotificationFilter
first: Int = 25
after: String
): NotificationFeedConnection!
notificationGroup(
groupId: String!
filter: NotificationFilter
first: Int = 25
after: String
): NotificationGroupConnection!
unseenNotificationCount(workspaceId: String, product: String): Int!
}
input NotificationFilter {
workspaceId: String
productFilter: String
}
type NotificationEntityModel{
objectId: String!
containerId: String
workspaceId: String
cloudId: String
}
type NotificationItem {
notificationId: ID!
entityModel: NotificationEntityModel
workspaceId: String
}
type NotificationHeadItem {
groupId: ID!
groupSize: Int!
readStates: [String]!
additionalTypes: [String!]!
headNotification: NotificationItem!
endCursor: String
}
type NotificationFeedConnection {
nodes: [NotificationHeadItem!]!
}
type NotificationGroupConnection {
nodes: [NotificationItem!]!
}
'''

when:
def changes = calcDiff(oldSdl, newSdl)

then:
changes.objectDifferences["NotificationGroupedItem"] === changes.objectDifferences["NotificationHeadItem"]
changes.objectDifferences["NotificationGroupedConnection"] === changes.objectDifferences["NotificationFeedConnection"]
changes.objectDifferences["NotificationGroupedItem"] instanceof ObjectModification
changes.objectDifferences["NotificationGroupedConnection"] instanceof ObjectModification
changes.objectDifferences["NotificationEntityModel"] instanceof ObjectAddition
changes.objectDifferences["NotificationGroupConnection"] instanceof ObjectAddition
changes.objectDifferences["NotificationItem"] instanceof ObjectModification
changes.objectDifferences["NotificationQuery"] instanceof ObjectModification

changes.inputObjectDifferences["NotificationFeedFilter"] === changes.inputObjectDifferences["NotificationFilter"]
changes.inputObjectDifferences["NotificationFeedFilter"] instanceof InputObjectModification

def notificationFeedFilterChange = changes.inputObjectDifferences["NotificationFeedFilter"] as InputObjectModification
notificationFeedFilterChange.details.size() == 1
notificationFeedFilterChange.details[0] instanceof InputObjectFieldDeletion
def groupIdInputObjectFieldDeletion = notificationFeedFilterChange.details[0] as InputObjectFieldDeletion
groupIdInputObjectFieldDeletion.name == "groupId"
}

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