Skip to content

Commit df9ba5c

Browse files
committed
documentation for Schema diffing
1 parent 167199e commit df9ba5c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/main/java/graphql/schema/diffing/PossibleMappingsCalculator.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@
3737
import static java.util.Collections.emptyList;
3838
import static java.util.Collections.singletonList;
3939

40+
/**
41+
* We don't want to allow arbitrary schema changes. For example changing an Object type into a Scalar
42+
* is not something we want to consider.
43+
* <p>
44+
* We do this to make SchemaDiffings better understandable, but also to improve the overall runtime of
45+
* the algorithm. By restricting the possible mappings the Schema diffing algo is actually able to
46+
* finish in a reasonable time for real life inputs.
47+
* <p>
48+
*
49+
* We restrict the algo by calculating which mappings are possible for given vertex. This is later used in
50+
* {@link DiffImpl#calcLowerBoundMappingCost}.
51+
* While doing this we need to also ensure that there are the same amount of vertices in the same "context":
52+
* for example if the source graph has 3 Objects, the target graph needs to have 3 Objects. We achieve this by
53+
* adding "isolated vertices" as needed.
54+
*/
4055
@Internal
4156
public class PossibleMappingsCalculator {
4257
private final SchemaDiffingRunningCheck runningCheck;
@@ -760,7 +775,7 @@ public VertexContextSegment(VertexContextSegment child) {
760775
public abstract boolean filter(Vertex vertex, SchemaGraph schemaGraph);
761776
}
762777

763-
public class PossibleMappings {
778+
public static class PossibleMappings {
764779

765780
public Set<Vertex> allIsolatedSource = new LinkedHashSet<>();
766781
public Set<Vertex> allIsolatedTarget = new LinkedHashSet<>();

0 commit comments

Comments
 (0)