Package graphql.schema.diff
Class SchemaDiff
- java.lang.Object
-
- graphql.schema.diff.SchemaDiff
-
@PublicSpi public class SchemaDiff extends java.lang.Object
The SchemaDiff is called with aDiffSetand will report the differences in the graphql schema APIs by raising events to aDifferenceReporter
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classSchemaDiff.CountingReporterstatic classSchemaDiff.OptionsOptions for controlling the diffing process
-
Field Summary
Fields Modifier and Type Field Description private SchemaDiff.Optionsoptionsprivate static java.util.Set<java.lang.String>SYSTEM_SCALARS
-
Constructor Summary
Constructors Constructor Description SchemaDiff()Constructs a differ using default optionsSchemaDiff(SchemaDiff.Options options)Constructs a differ with the specified options
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private static java.lang.Stringcapitalize(java.lang.String name)private voidcheckDirectives(DiffCtx ctx, TypeDefinition oldDef, TypeDefinition newDef)(package private) voidcheckDirectives(DiffCtx ctx, TypeDefinition old, java.util.List<Directive> oldDirectives, java.util.List<Directive> newDirectives)private voidcheckEnumType(DiffCtx ctx, EnumTypeDefinition oldDef, EnumTypeDefinition newDef)private voidcheckField(DiffCtx ctx, TypeDefinition old, FieldDefinition oldField, FieldDefinition newField)private voidcheckFieldAdditions(DiffCtx ctx, TypeDefinition newDef, java.util.Map<java.lang.String,FieldDefinition> oldFields, java.util.Map<java.lang.String,FieldDefinition> newFields)private voidcheckFieldArg(DiffCtx ctx, TypeDefinition oldDef, FieldDefinition oldField, InputValueDefinition oldArg, InputValueDefinition newArg)private voidcheckFieldArguments(DiffCtx ctx, TypeDefinition oldDef, FieldDefinition oldField, java.util.List<InputValueDefinition> oldInputValueDefinitions, java.util.List<InputValueDefinition> newInputValueDefinitions)private voidcheckFieldRemovals(DiffCtx ctx, TypeDefinition oldDef, java.util.Map<java.lang.String,FieldDefinition> oldFields, java.util.Map<java.lang.String,FieldDefinition> newFields)private voidcheckFields(DiffCtx ctx, TypeDefinition oldDef, java.util.Map<java.lang.String,FieldDefinition> oldFields, TypeDefinition newDef, java.util.Map<java.lang.String,FieldDefinition> newFields)private voidcheckImplements(DiffCtx ctx, ObjectTypeDefinition old, java.util.List<Type> oldImplements, java.util.List<Type> newImplements)private voidcheckInputFields(DiffCtx ctx, TypeDefinition old, java.util.List<InputValueDefinition> oldIVD, java.util.List<InputValueDefinition> newIVD)private voidcheckInputObjectType(DiffCtx ctx, InputObjectTypeDefinition oldDef, InputObjectTypeDefinition newDef)private voidcheckInterfaceType(DiffCtx ctx, InterfaceTypeDefinition oldDef, InterfaceTypeDefinition newDef)private voidcheckObjectType(DiffCtx ctx, ObjectTypeDefinition oldDef, ObjectTypeDefinition newDef)private voidcheckOperation(DiffCtx ctx, java.lang.String opName, java.util.Optional<SchemaDefinition> oldSchemaDef, java.util.Optional<SchemaDefinition> newSchemaDef)private voidcheckScalarType(DiffCtx ctx, ScalarTypeDefinition oldDef, ScalarTypeDefinition newDef)private voidcheckType(DiffCtx ctx, Type oldType, Type newType)(package private) DiffCategorycheckTypeWithNonNullAndListOnInputOrArg(Type oldType, Type newType)(package private) DiffCategorycheckTypeWithNonNullAndListOnObjectOrInterface(Type oldType, Type newType)private voidcheckUnionType(DiffCtx ctx, UnionTypeDefinition oldDef, UnionTypeDefinition newDef)intdiffSchema(DiffSet diffSet, DifferenceReporter reporter)Deprecated.intdiffSchema(SchemaDiffSet schemaDiffSet, DifferenceReporter reporter)This will perform a difference on the two schemas.private voiddiffSchemaImpl(Document oldDoc, Document newDoc, DifferenceReporter reporter)private java.util.Optional<OperationTypeDefinition>getOpDef(java.lang.String opName, SchemaDefinition schemaDef)private java.util.Optional<SchemaDefinition>getSchemaDef(Document document)(package private) static java.lang.StringgetTypeName(Type type)private booleanisDeprecated(DirectivesContainer<?> node)private booleanisReservedType(java.lang.String typeName)private booleanisSystemScalar(java.lang.String typeName)private java.lang.StringmkDotName(java.lang.String... objectNames)private <T> java.util.Map<java.lang.String,T>sortedMap(java.util.List<T> listOfNamedThings, java.util.function.Function<T,java.lang.String> nameFunc)private java.util.Optional<OperationTypeDefinition>synthOperationTypeDefinition(java.util.function.Function<Type,java.util.Optional<ObjectTypeDefinition>> typeRetriever, java.lang.String opName)
-
-
-
Field Detail
-
options
private final SchemaDiff.Options options
-
SYSTEM_SCALARS
private static final java.util.Set<java.lang.String> SYSTEM_SCALARS
-
-
Constructor Detail
-
SchemaDiff
public SchemaDiff()
Constructs a differ using default options
-
SchemaDiff
public SchemaDiff(SchemaDiff.Options options)
Constructs a differ with the specified options- Parameters:
options- the controlling options
-
-
Method Detail
-
diffSchema
@Deprecated public int diffSchema(DiffSet diffSet, DifferenceReporter reporter)
Deprecated.This will perform a difference on the two schemas. The reporter callback interface will be called when differences are encountered.- Parameters:
diffSet- the two schemas to compare for differencereporter- the place to report difference events to- Returns:
- the number of API breaking changes
-
diffSchema
public int diffSchema(SchemaDiffSet schemaDiffSet, DifferenceReporter reporter)
This will perform a difference on the two schemas. The reporter callback interface will be called when differences are encountered.- Parameters:
schemaDiffSet- the two schemas to compare for differencereporter- the place to report difference events to- Returns:
- the number of API breaking changes
-
diffSchemaImpl
private void diffSchemaImpl(Document oldDoc, Document newDoc, DifferenceReporter reporter)
-
checkOperation
private void checkOperation(DiffCtx ctx, java.lang.String opName, java.util.Optional<SchemaDefinition> oldSchemaDef, java.util.Optional<SchemaDefinition> newSchemaDef)
-
isDeprecated
private boolean isDeprecated(DirectivesContainer<?> node)
-
isReservedType
private boolean isReservedType(java.lang.String typeName)
-
isSystemScalar
private boolean isSystemScalar(java.lang.String typeName)
-
checkObjectType
private void checkObjectType(DiffCtx ctx, ObjectTypeDefinition oldDef, ObjectTypeDefinition newDef)
-
checkInterfaceType
private void checkInterfaceType(DiffCtx ctx, InterfaceTypeDefinition oldDef, InterfaceTypeDefinition newDef)
-
checkUnionType
private void checkUnionType(DiffCtx ctx, UnionTypeDefinition oldDef, UnionTypeDefinition newDef)
-
checkInputObjectType
private void checkInputObjectType(DiffCtx ctx, InputObjectTypeDefinition oldDef, InputObjectTypeDefinition newDef)
-
checkInputFields
private void checkInputFields(DiffCtx ctx, TypeDefinition old, java.util.List<InputValueDefinition> oldIVD, java.util.List<InputValueDefinition> newIVD)
-
checkEnumType
private void checkEnumType(DiffCtx ctx, EnumTypeDefinition oldDef, EnumTypeDefinition newDef)
-
checkScalarType
private void checkScalarType(DiffCtx ctx, ScalarTypeDefinition oldDef, ScalarTypeDefinition newDef)
-
checkImplements
private void checkImplements(DiffCtx ctx, ObjectTypeDefinition old, java.util.List<Type> oldImplements, java.util.List<Type> newImplements)
-
checkFields
private void checkFields(DiffCtx ctx, TypeDefinition oldDef, java.util.Map<java.lang.String,FieldDefinition> oldFields, TypeDefinition newDef, java.util.Map<java.lang.String,FieldDefinition> newFields)
-
checkFieldRemovals
private void checkFieldRemovals(DiffCtx ctx, TypeDefinition oldDef, java.util.Map<java.lang.String,FieldDefinition> oldFields, java.util.Map<java.lang.String,FieldDefinition> newFields)
-
checkFieldAdditions
private void checkFieldAdditions(DiffCtx ctx, TypeDefinition newDef, java.util.Map<java.lang.String,FieldDefinition> oldFields, java.util.Map<java.lang.String,FieldDefinition> newFields)
-
checkField
private void checkField(DiffCtx ctx, TypeDefinition old, FieldDefinition oldField, FieldDefinition newField)
-
checkFieldArguments
private void checkFieldArguments(DiffCtx ctx, TypeDefinition oldDef, FieldDefinition oldField, java.util.List<InputValueDefinition> oldInputValueDefinitions, java.util.List<InputValueDefinition> newInputValueDefinitions)
-
checkFieldArg
private void checkFieldArg(DiffCtx ctx, TypeDefinition oldDef, FieldDefinition oldField, InputValueDefinition oldArg, InputValueDefinition newArg)
-
checkDirectives
private void checkDirectives(DiffCtx ctx, TypeDefinition oldDef, TypeDefinition newDef)
-
checkDirectives
void checkDirectives(DiffCtx ctx, TypeDefinition old, java.util.List<Directive> oldDirectives, java.util.List<Directive> newDirectives)
-
checkTypeWithNonNullAndListOnInputOrArg
DiffCategory checkTypeWithNonNullAndListOnInputOrArg(Type oldType, Type newType)
-
checkTypeWithNonNullAndListOnObjectOrInterface
DiffCategory checkTypeWithNonNullAndListOnObjectOrInterface(Type oldType, Type newType)
-
getTypeName
static java.lang.String getTypeName(Type type)
-
getSchemaDef
private java.util.Optional<SchemaDefinition> getSchemaDef(Document document)
-
getOpDef
private java.util.Optional<OperationTypeDefinition> getOpDef(java.lang.String opName, SchemaDefinition schemaDef)
-
synthOperationTypeDefinition
private java.util.Optional<OperationTypeDefinition> synthOperationTypeDefinition(java.util.function.Function<Type,java.util.Optional<ObjectTypeDefinition>> typeRetriever, java.lang.String opName)
-
sortedMap
private <T> java.util.Map<java.lang.String,T> sortedMap(java.util.List<T> listOfNamedThings, java.util.function.Function<T,java.lang.String> nameFunc)
-
capitalize
private static java.lang.String capitalize(java.lang.String name)
-
mkDotName
private java.lang.String mkDotName(java.lang.String... objectNames)
-
-