@PublicApi public class TypeDefinitionRegistry extends java.lang.Object
TypeDefinitionRegistry
contains the set of type definitions that come from compiling
a graphql schema definition file via SchemaParser.parse(String)
Constructor and Description |
---|
TypeDefinitionRegistry() |
Modifier and Type | Method and Description |
---|---|
java.util.Optional<GraphQLError> |
add(SDLDefinition definition)
Adds a definition to the registry
|
java.util.Optional<GraphQLError> |
addAll(java.util.Collection<SDLDefinition> definitions)
Adds a a collections of definitions to the registry
|
java.util.Map<java.lang.String,java.util.List<EnumTypeExtensionDefinition>> |
enumTypeExtensions() |
java.util.Optional<DirectiveDefinition> |
getDirectiveDefinition(java.lang.String directiveName) |
java.util.Map<java.lang.String,DirectiveDefinition> |
getDirectiveDefinitions() |
java.util.List<ObjectTypeDefinition> |
getImplementationsOf(InterfaceTypeDefinition targetInterface)
Returns the list of object types that implement the given interface type
|
java.util.Optional<TypeDefinition> |
getType(java.lang.String typeName) |
<T extends TypeDefinition> |
getType(java.lang.String typeName,
java.lang.Class<T> ofType) |
java.util.Optional<TypeDefinition> |
getType(Type type) |
<T extends TypeDefinition> |
getType(Type type,
java.lang.Class<T> ofType) |
<T extends TypeDefinition> |
getTypes(java.lang.Class<T> targetClass)
Returns a list of types in the registry of that specified class
|
<T extends TypeDefinition> |
getTypesMap(java.lang.Class<T> targetClass)
Returns a map of types in the registry of that specified class keyed by name
|
boolean |
hasType(TypeName typeName) |
java.util.Map<java.lang.String,java.util.List<InputObjectTypeExtensionDefinition>> |
inputObjectTypeExtensions() |
java.util.Map<java.lang.String,java.util.List<InterfaceTypeExtensionDefinition>> |
interfaceTypeExtensions() |
boolean |
isInterfaceOrUnion(Type type)
Returns true if the specified type exists in the registry and is an abstract (Interface or Union) type
|
boolean |
isObjectType(Type type)
Returns true if the specified type exists in the registry and is an object type
|
boolean |
isPossibleType(Type abstractType,
Type possibleObjectType)
Returns true of the abstract type is in implemented by the object type
|
boolean |
isSubTypeOf(Type maybeSubType,
Type superType)
Returns true if the maybe type is either equal or a subset of the second super type (covariant).
|
TypeDefinitionRegistry |
merge(TypeDefinitionRegistry typeRegistry)
This will merge these type registries together and return this one
|
java.util.Map<java.lang.String,java.util.List<ObjectTypeExtensionDefinition>> |
objectTypeExtensions() |
void |
remove(SDLDefinition definition) |
java.util.Map<java.lang.String,ScalarTypeDefinition> |
scalars() |
java.util.Map<java.lang.String,java.util.List<ScalarTypeExtensionDefinition>> |
scalarTypeExtensions() |
java.util.Optional<SchemaDefinition> |
schemaDefinition() |
java.util.Map<java.lang.String,TypeDefinition> |
types() |
java.util.Map<java.lang.String,java.util.List<UnionTypeExtensionDefinition>> |
unionTypeExtensions() |
public TypeDefinitionRegistry merge(TypeDefinitionRegistry typeRegistry) throws SchemaProblem
typeRegistry
- the registry to be merged into this oneSchemaProblem
- if there are problems merging the types such as redefinitionspublic java.util.Optional<GraphQLError> addAll(java.util.Collection<SDLDefinition> definitions)
definitions
- the definitions to addpublic java.util.Optional<GraphQLError> add(SDLDefinition definition)
definition
- the definition to addpublic void remove(SDLDefinition definition)
public java.util.Map<java.lang.String,TypeDefinition> types()
public java.util.Map<java.lang.String,ScalarTypeDefinition> scalars()
public java.util.Map<java.lang.String,java.util.List<ObjectTypeExtensionDefinition>> objectTypeExtensions()
public java.util.Map<java.lang.String,java.util.List<InterfaceTypeExtensionDefinition>> interfaceTypeExtensions()
public java.util.Map<java.lang.String,java.util.List<UnionTypeExtensionDefinition>> unionTypeExtensions()
public java.util.Map<java.lang.String,java.util.List<EnumTypeExtensionDefinition>> enumTypeExtensions()
public java.util.Map<java.lang.String,java.util.List<ScalarTypeExtensionDefinition>> scalarTypeExtensions()
public java.util.Map<java.lang.String,java.util.List<InputObjectTypeExtensionDefinition>> inputObjectTypeExtensions()
public java.util.Optional<SchemaDefinition> schemaDefinition()
public java.util.Optional<DirectiveDefinition> getDirectiveDefinition(java.lang.String directiveName)
public java.util.Map<java.lang.String,DirectiveDefinition> getDirectiveDefinitions()
public boolean hasType(TypeName typeName)
public java.util.Optional<TypeDefinition> getType(Type type)
public <T extends TypeDefinition> java.util.Optional<T> getType(Type type, java.lang.Class<T> ofType)
public java.util.Optional<TypeDefinition> getType(java.lang.String typeName)
public <T extends TypeDefinition> java.util.Optional<T> getType(java.lang.String typeName, java.lang.Class<T> ofType)
public boolean isInterfaceOrUnion(Type type)
type
- the type to checkpublic boolean isObjectType(Type type)
type
- the type to checkpublic <T extends TypeDefinition> java.util.List<T> getTypes(java.lang.Class<T> targetClass)
T
- must extend TypeDefinitiontargetClass
- the class to search forpublic <T extends TypeDefinition> java.util.Map<java.lang.String,T> getTypesMap(java.lang.Class<T> targetClass)
T
- must extend TypeDefinitiontargetClass
- the class to search forpublic java.util.List<ObjectTypeDefinition> getImplementationsOf(InterfaceTypeDefinition targetInterface)
targetInterface
- the target to search forpublic boolean isPossibleType(Type abstractType, Type possibleObjectType)
abstractType
- the abstract type to check (interface or union)possibleObjectType
- the object type to checkpublic boolean isSubTypeOf(Type maybeSubType, Type superType)
maybeSubType
- the type to checksuperType
- the equality checked type