Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
c35d162
create a schema graph
andimarek Nov 12, 2021
f471923
maybe something working
andimarek Nov 14, 2021
7ff9578
wip
andimarek Nov 16, 2021
a718a91
wip
andimarek Nov 16, 2021
7652c68
delete field working
andimarek Nov 16, 2021
4c58b4c
tests
andimarek Nov 16, 2021
7c50636
tests
andimarek Nov 17, 2021
9f1a1f0
wip
andimarek Nov 29, 2021
8e92873
optimizing a bit and testing large schemas
andimarek Dec 6, 2021
81c366a
wip
andimarek Dec 9, 2021
6046ab6
wip
andimarek Dec 9, 2021
22e1148
wip
andimarek Dec 9, 2021
6963902
wip
andimarek Dec 9, 2021
dad0fbd
higher level diff analyzer
andimarek Dec 9, 2021
36ee1d8
performance
andimarek Dec 10, 2021
7c662fa
performance
andimarek Dec 10, 2021
00d08da
sorting work
andimarek Dec 10, 2021
8be4509
sorting work
andimarek Dec 10, 2021
570a67e
generate all children at once
andimarek Dec 15, 2021
400a635
cleanup ab it
andimarek Dec 15, 2021
89575a7
cleanup
andimarek Dec 15, 2021
5d817fa
simplify
andimarek Dec 15, 2021
aa007e4
testing
andimarek Dec 15, 2021
b0cc0d9
optimizing
andimarek Dec 17, 2021
8481583
cleanup
andimarek Dec 17, 2021
986cbe6
fix bug regarding input object fields, tests
andimarek Dec 19, 2021
32a6501
performance work
andimarek Dec 19, 2021
7829b03
performance work
andimarek Dec 20, 2021
b22f505
mino
andimarek Jan 4, 2022
9baa577
performance work
andimarek Jan 4, 2022
32b4f9b
performance work
andimarek Jan 4, 2022
ac01af8
parallel version
andimarek Jan 4, 2022
b07c5c3
performance
andimarek Jan 4, 2022
62bfaa9
handling of isolated vertices
andimarek Jan 5, 2022
48ce479
most parallel version
andimarek Jan 5, 2022
fee3be3
performance
andimarek Jan 7, 2022
410cb49
handle fields better
andimarek Jan 7, 2022
06803c1
improve isMatchingPossible
andimarek Jan 7, 2022
f82d2f1
bugfixing
andimarek Jan 7, 2022
16c7496
only sort if diff size is not zero
andimarek Jan 7, 2022
0264bcf
handle input fields correctly
andimarek Jan 28, 2022
e0ae0c5
reworked isolated vertices handling.
andimarek Feb 9, 2022
bca1f40
wip
andimarek Feb 9, 2022
8b55bf1
wip
andimarek Feb 9, 2022
a1a45c5
fixing isolated vertices handling
andimarek Feb 9, 2022
e1dbb90
tests
andimarek Feb 10, 2022
e00980f
more test, directives handling
andimarek Feb 10, 2022
57cb92f
applied arguments handling
andimarek Feb 10, 2022
9f73703
isolated handling
andimarek Feb 10, 2022
c54cb33
sorting work
andimarek Feb 11, 2022
836288c
reworked possible mapping handling
andimarek Feb 14, 2022
a9b8d9a
wip
andimarek Feb 14, 2022
36946ef
wip
andimarek Feb 14, 2022
f39a46a
wip
andimarek Feb 14, 2022
d134676
wip
andimarek Feb 14, 2022
7946884
wip
andimarek Feb 14, 2022
3795fa2
wip
andimarek Feb 14, 2022
2f17e6b
all tests green
andimarek Feb 14, 2022
6278fa9
cleanup
andimarek Sep 30, 2022
374d962
cleanup
andimarek Sep 30, 2022
a06a5bc
cleanup
andimarek Sep 30, 2022
c91e79b
cleanup
andimarek Sep 30, 2022
73be22a
test green
andimarek Oct 4, 2022
9d9afd8
consider impossible mappings
andimarek Oct 4, 2022
e3ea10f
sort source element
andimarek Oct 5, 2022
785ff9e
cleanup
andimarek Oct 5, 2022
e715297
cleanup
andimarek Oct 5, 2022
fa4624b
refactoring
andimarek Oct 5, 2022
389eeb9
refactoring
andimarek Oct 6, 2022
3704492
save all edit operations
andimarek Oct 6, 2022
55a3f59
improve mapping
andimarek Oct 6, 2022
bb3b4e5
work
andimarek Oct 6, 2022
f4d7294
work
andimarek Oct 6, 2022
05891a4
edit operation analyzer
andimarek Oct 6, 2022
60d8030
edit operation analyzer
andimarek Oct 7, 2022
62474ad
edit operation analyzer
andimarek Oct 7, 2022
fbbf52b
work
andimarek Oct 7, 2022
58681a8
work
andimarek Oct 7, 2022
1e5285d
change to directed graph
andimarek Oct 7, 2022
fadc496
wip
andimarek Oct 7, 2022
2fb6d87
changed calc lower bound
andimarek Oct 7, 2022
8741b66
changed calc lower bound
andimarek Oct 7, 2022
9be24ee
tests green
andimarek Oct 8, 2022
7268b13
edit operation analyzer wip
andimarek Oct 8, 2022
a87c1dc
edit operation analyzer wip
andimarek Oct 8, 2022
7f5737c
edit operation analyzer wip
andimarek Oct 8, 2022
f3b10fb
edit operation analyzer wip
andimarek Oct 8, 2022
4d7bc53
old schema diff test
andimarek Oct 10, 2022
7a3f7eb
add schema vertex
andimarek Oct 10, 2022
29d38cf
schema directives
andimarek Oct 10, 2022
c372a95
cleanup
andimarek Oct 11, 2022
702fb4e
descriptions
andimarek Oct 11, 2022
669b1f0
testing
andimarek Oct 11, 2022
b24e082
default values
andimarek Oct 11, 2022
7329371
cleanup
andimarek Oct 11, 2022
6921daa
Merge branch 'master' into schema-graph-directed-refactor
andimarek Oct 11, 2022
a663950
fix test
andimarek Oct 11, 2022
b3f34cd
cleanup
andimarek Oct 11, 2022
49482b1
object field type changes
andimarek Oct 20, 2022
073b81b
object field type changes
andimarek Oct 20, 2022
c7ae4dd
work on higher level schema diff
andimarek Oct 24, 2022
dcb648b
work on higher level schema diff
andimarek Oct 24, 2022
9324a22
work on higher level schema diff
andimarek Oct 24, 2022
97f93ca
work on higher level schema diff
andimarek Oct 25, 2022
0c1cd4f
work on higher level schema diff
andimarek Oct 25, 2022
df04e36
work on higher level schema diff
andimarek Oct 25, 2022
6358d26
work on higher level schema diff
andimarek Oct 25, 2022
33bce7f
work on higher level schema diff
andimarek Oct 25, 2022
573308d
work on higher level schema diff
andimarek Oct 25, 2022
729cf2a
work on higher level schema diff
andimarek Oct 25, 2022
7a06b9f
work on higher level schema diff
andimarek Oct 25, 2022
23129dc
work on higher level schema diff
andimarek Oct 26, 2022
866415a
work on higher level schema diff
andimarek Oct 27, 2022
630fc92
work on higher level schema diff
andimarek Oct 27, 2022
2b7edb5
work on higher level schema diff
andimarek Oct 27, 2022
cfe6d11
work on higher level schema diff
andimarek Oct 27, 2022
a5ce151
work on higher level schema diff
andimarek Oct 27, 2022
b9210a0
work on higher level schema diff
andimarek Oct 27, 2022
5d20db2
work on higher level schema diff
andimarek Oct 27, 2022
ba56a65
work on higher level schema diff
andimarek Oct 27, 2022
0d4b64e
work on higher level schema diff
andimarek Oct 27, 2022
e278bbb
work on higher level schema diff
andimarek Oct 27, 2022
2e51d6f
work on higher level schema diff
andimarek Oct 27, 2022
72fc2cd
work on higher level schema diff
andimarek Oct 27, 2022
7e61c2c
work on higher level schema diff
andimarek Oct 27, 2022
579b378
work on higher level schema diff
andimarek Oct 27, 2022
d46169d
work on higher level schema diff
andimarek Oct 27, 2022
a22eb44
work on higher level schema diff
andimarek Oct 27, 2022
e79ca1f
work on higher level schema diff
andimarek Oct 28, 2022
8951a75
higher level diff work
andimarek Oct 29, 2022
497b05d
higher level diff work
andimarek Oct 29, 2022
9b9449c
Merge branch 'master' into schema-graph-directed-refactor
andimarek Oct 29, 2022
17a8d56
fix test
andimarek Oct 29, 2022
426f4ab
higher level schema diffing work
andimarek Oct 29, 2022
e9b97b6
work on higher level schema diff
andimarek Nov 3, 2022
9ab70cd
work on higher level schema diff
andimarek Nov 3, 2022
a2ac1e6
work on higher level schema diff
andimarek Nov 4, 2022
be6b7af
work on higher level schema diff
andimarek Nov 4, 2022
03c8592
work on higher level schema diff
andimarek Nov 4, 2022
d76435b
work on higher level schema diff
andimarek Nov 5, 2022
8e35695
work on higher level schema diff
andimarek Nov 7, 2022
635832b
work on higher level schema diff
andimarek Nov 7, 2022
9f06749
work on higher level schema diff
andimarek Nov 7, 2022
c74c067
work on higher level schema diff
andimarek Nov 7, 2022
2f456ce
work on higher level schema diff
andimarek Nov 7, 2022
26d0ad6
work on higher level schema diff
andimarek Nov 7, 2022
75ad028
work on higher level schema diff
andimarek Nov 7, 2022
e4caa34
work on higher level schema diff
andimarek Nov 10, 2022
dd4ac62
work on higher level schema diff
andimarek Nov 10, 2022
d846a57
work on higher level schema diff
andimarek Nov 10, 2022
aa5afc6
work on higher level schema diff
andimarek Nov 11, 2022
59f80f6
work on higher level schema diff
andimarek Nov 11, 2022
2e9f18c
work on higher level schema diff
andimarek Nov 11, 2022
48e2913
Merge branch 'master' into schema-graph-directed-refactor
andimarek Nov 11, 2022
7550550
Merge branch 'master' into schema-graph-directed-refactor
andimarek Nov 11, 2022
d4474d9
work on higher level schema diff
andimarek Nov 11, 2022
e10dc8b
Merge branch 'master' into schema-graph-directed-refactor
andimarek Nov 12, 2022
5329298
work on higher level schema diff
andimarek Nov 12, 2022
e7b8071
work on higher level schema diff
andimarek Nov 12, 2022
4b1f46e
work on higher level schema diff
andimarek Nov 12, 2022
90ad29d
work on higher level schema diff
andimarek Nov 12, 2022
d16414d
mark everything as internal for now
andimarek Nov 29, 2022
1d0fdbf
improved test
andimarek Nov 29, 2022
0e4c2f3
improved test
andimarek Nov 29, 2022
a12a590
Merge branch 'master' into schema-graph-directed-refactor
andimarek Nov 29, 2022
08cdb58
fix test
andimarek Nov 29, 2022
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
3 changes: 2 additions & 1 deletion src/main/java/graphql/Mutable.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;

/**
* This marks a type as mutable which means after constructing it can be changed.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(value = {TYPE})
@Target(value = {TYPE,METHOD})
public @interface Mutable {
}
415 changes: 415 additions & 0 deletions src/main/java/graphql/schema/diffing/DiffImpl.java

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions src/main/java/graphql/schema/diffing/Edge.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package graphql.schema.diffing;

import graphql.Internal;

import java.util.Objects;

@Internal
public class Edge {
private Vertex from;
private Vertex to;

private String label = "";

public Edge(Vertex from, Vertex to) {
this.from = from;
this.to = to;
}

public Edge(Vertex from, Vertex to, String label) {
this.from = from;
this.to = to;
this.label = label;
}

public Vertex getFrom() {
return from;
}

public void setFrom(Vertex from) {
this.from = from;
}

public Vertex getTo() {
return to;
}

public void setTo(Vertex to) {
this.to = to;
}


public void setLabel(String label) {
this.label = label;
}

public String getLabel() {
return label;
}

@Override
public String toString() {
return "Edge{" +
"from=" + from +
", to=" + to +
", label='" + label + '\'' +
'}';
}

public boolean isEqualTo(Edge other) {
return Objects.equals(this.label, other.label);
}
}
107 changes: 107 additions & 0 deletions src/main/java/graphql/schema/diffing/EditOperation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package graphql.schema.diffing;

import graphql.Internal;

import java.util.Objects;

@Internal
public class EditOperation {

private EditOperation(Operation operation,
String description,
Vertex sourceVertex,
Vertex targetVertex,
Edge sourceEdge,
Edge targetEdge) {
this.operation = operation;
this.description = description;
this.sourceVertex = sourceVertex;
this.targetVertex = targetVertex;
this.sourceEdge = sourceEdge;
this.targetEdge = targetEdge;
}

public static EditOperation deleteVertex(String description, Vertex sourceVertex,Vertex targetVertex) {
return new EditOperation(Operation.DELETE_VERTEX, description, sourceVertex, targetVertex, null, null);
}

public static EditOperation insertVertex(String description,Vertex sourceVertex, Vertex targetVertex) {
return new EditOperation(Operation.INSERT_VERTEX, description, sourceVertex, targetVertex, null, null);
}

public static EditOperation changeVertex(String description, Vertex sourceVertex, Vertex targetVertex) {
return new EditOperation(Operation.CHANGE_VERTEX, description, sourceVertex, targetVertex, null, null);
}

public static EditOperation deleteEdge(String description, Edge sourceEdge) {
return new EditOperation(Operation.DELETE_EDGE, description, null, null, sourceEdge, null);
}

public static EditOperation insertEdge(String description, Edge targetEdge) {
return new EditOperation(Operation.INSERT_EDGE, description, null, null, null, targetEdge);
}

public static EditOperation changeEdge(String description, Edge sourceEdge, Edge targetEdge) {
return new EditOperation(Operation.CHANGE_EDGE, description, null, null, sourceEdge, targetEdge);
}

private Operation operation;
private String description;
private Vertex sourceVertex;
private Vertex targetVertex;
private Edge sourceEdge;
private Edge targetEdge;


public enum Operation {
CHANGE_VERTEX, DELETE_VERTEX, INSERT_VERTEX, CHANGE_EDGE, INSERT_EDGE, DELETE_EDGE
}

public Operation getOperation() {
return operation;
}


public Vertex getSourceVertex() {
return sourceVertex;
}

public Vertex getTargetVertex() {
return targetVertex;
}

public Edge getSourceEdge() {
return sourceEdge;
}

public Edge getTargetEdge() {
return targetEdge;
}

@Override
public String toString() {
return "EditOperation{" +
"operation=" + operation +
", description='" + description + '\'' +
'}';
}



@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
EditOperation that = (EditOperation) o;
return operation == that.operation && Objects.equals(description, that.description) && Objects.equals(sourceVertex, that.sourceVertex) && Objects.equals(targetVertex, that.targetVertex) && Objects.equals(sourceEdge, that.sourceEdge) && Objects.equals(targetEdge, that.targetEdge);
}

@Override
public int hashCode() {
return Objects.hash(operation, description, sourceVertex, targetVertex, sourceEdge, targetEdge);
}
}
70 changes: 70 additions & 0 deletions src/main/java/graphql/schema/diffing/EditorialCostForMapping.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package graphql.schema.diffing;

import graphql.Internal;

import java.util.List;

@Internal
public class EditorialCostForMapping {

/**
* a mapping introduces a subgraph consisting of all vertices and all edges between these vertices
*/
public static int editorialCostForMapping(Mapping mapping, // can be a partial mapping
SchemaGraph sourceGraph, // the whole graph
SchemaGraph targetGraph, // the whole graph
List<EditOperation> editOperationsResult) {
int cost = 0;
for (int i = 0; i < mapping.size(); i++) {
Vertex sourceVertex = mapping.getSource(i);
Vertex targetVertex = mapping.getTarget(i);
// Vertex changing (relabeling)
boolean equalNodes = sourceVertex.getType().equals(targetVertex.getType()) && sourceVertex.getProperties().equals(targetVertex.getProperties());
if (!equalNodes) {
if (sourceVertex.isIsolated()) {
editOperationsResult.add(EditOperation.insertVertex("Insert" + targetVertex, sourceVertex, targetVertex));
} else if (targetVertex.isIsolated()) {
editOperationsResult.add(EditOperation.deleteVertex("Delete " + sourceVertex, sourceVertex, targetVertex));
} else {
editOperationsResult.add(EditOperation.changeVertex("Change " + sourceVertex + " to " + targetVertex, sourceVertex, targetVertex));
}
cost++;
}
}
List<Edge> edges = sourceGraph.getEdges();
// edge deletion or relabeling
for (Edge sourceEdge : edges) {
// only edges relevant to the subgraph
if (!mapping.containsSource(sourceEdge.getFrom()) || !mapping.containsSource(sourceEdge.getTo())) {
continue;
}
Vertex targetFrom = mapping.getTarget(sourceEdge.getFrom());
Vertex targetTo = mapping.getTarget(sourceEdge.getTo());
Edge targetEdge = targetGraph.getEdge(targetFrom, targetTo);
if (targetEdge == null) {
editOperationsResult.add(EditOperation.deleteEdge("Delete edge " + sourceEdge, sourceEdge));
cost++;
} else if (!sourceEdge.getLabel().equals(targetEdge.getLabel())) {
editOperationsResult.add(EditOperation.changeEdge("Change " + sourceEdge + " to " + targetEdge, sourceEdge, targetEdge));
cost++;
}
}

//TODO: iterates over all edges in the target Graph
for (Edge targetEdge : targetGraph.getEdges()) {
// only subgraph edges
if (!mapping.containsTarget(targetEdge.getFrom()) || !mapping.containsTarget(targetEdge.getTo())) {
continue;
}
Vertex sourceFrom = mapping.getSource(targetEdge.getFrom());
Vertex sourceTo = mapping.getSource(targetEdge.getTo());
if (sourceGraph.getEdge(sourceFrom, sourceTo) == null) {
editOperationsResult.add(EditOperation.insertEdge("Insert edge " + targetEdge, targetEdge));
cost++;
}
}
return cost;
}


}
Loading