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 aDiffSet
and 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 class
SchemaDiff.CountingReporter
static class
SchemaDiff.Options
Options for controlling the diffing process
-
Field Summary
Fields Modifier and Type Field Description private SchemaDiff.Options
options
private 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.String
capitalize(java.lang.String name)
private void
checkDirectives(DiffCtx ctx, TypeDefinition oldDef, TypeDefinition newDef)
(package private) void
checkDirectives(DiffCtx ctx, TypeDefinition old, java.util.List<Directive> oldDirectives, java.util.List<Directive> newDirectives)
private void
checkEnumType(DiffCtx ctx, EnumTypeDefinition oldDef, EnumTypeDefinition newDef)
private void
checkField(DiffCtx ctx, TypeDefinition old, FieldDefinition oldField, FieldDefinition newField)
private void
checkFieldAdditions(DiffCtx ctx, TypeDefinition newDef, java.util.Map<java.lang.String,FieldDefinition> oldFields, java.util.Map<java.lang.String,FieldDefinition> newFields)
private void
checkFieldArg(DiffCtx ctx, TypeDefinition oldDef, FieldDefinition oldField, InputValueDefinition oldArg, InputValueDefinition newArg)
private void
checkFieldArguments(DiffCtx ctx, TypeDefinition oldDef, FieldDefinition oldField, java.util.List<InputValueDefinition> oldInputValueDefinitions, java.util.List<InputValueDefinition> newInputValueDefinitions)
private void
checkFieldRemovals(DiffCtx ctx, TypeDefinition oldDef, java.util.Map<java.lang.String,FieldDefinition> oldFields, java.util.Map<java.lang.String,FieldDefinition> newFields)
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)
private void
checkImplements(DiffCtx ctx, ObjectTypeDefinition old, java.util.List<Type> oldImplements, java.util.List<Type> newImplements)
private void
checkInputFields(DiffCtx ctx, TypeDefinition old, java.util.List<InputValueDefinition> oldIVD, java.util.List<InputValueDefinition> newIVD)
private void
checkInputObjectType(DiffCtx ctx, InputObjectTypeDefinition oldDef, InputObjectTypeDefinition newDef)
private void
checkInterfaceType(DiffCtx ctx, InterfaceTypeDefinition oldDef, InterfaceTypeDefinition newDef)
private void
checkObjectType(DiffCtx ctx, ObjectTypeDefinition oldDef, ObjectTypeDefinition newDef)
private void
checkOperation(DiffCtx ctx, java.lang.String opName, java.util.Optional<SchemaDefinition> oldSchemaDef, java.util.Optional<SchemaDefinition> newSchemaDef)
private void
checkScalarType(DiffCtx ctx, ScalarTypeDefinition oldDef, ScalarTypeDefinition newDef)
private void
checkType(DiffCtx ctx, Type oldType, Type newType)
(package private) DiffCategory
checkTypeWithNonNullAndListOnInputOrArg(Type oldType, Type newType)
(package private) DiffCategory
checkTypeWithNonNullAndListOnObjectOrInterface(Type oldType, Type newType)
private void
checkUnionType(DiffCtx ctx, UnionTypeDefinition oldDef, UnionTypeDefinition newDef)
int
diffSchema(DiffSet diffSet, DifferenceReporter reporter)
Deprecated.int
diffSchema(SchemaDiffSet schemaDiffSet, DifferenceReporter reporter)
This will perform a difference on the two schemas.private void
diffSchemaImpl(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.String
getTypeName(Type type)
private boolean
isDeprecated(DirectivesContainer<?> node)
private boolean
isReservedType(java.lang.String typeName)
private boolean
isSystemScalar(java.lang.String typeName)
private java.lang.String
mkDotName(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)
-
-