@PublicApi public class TypeDefinitionRegistry extends java.lang.Object implements java.io.Serializable
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.List<ImplementingTypeDefinition> |
getAllImplementationsOf(InterfaceTypeDefinition targetInterface)
Returns the list of object and interface types that implement the given interface type
|
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 interface types that implement the given interface type
|
SchemaParseOrder |
getParseOrder() |
java.util.List<SchemaExtensionDefinition> |
getSchemaExtensionDefinitions() |
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 |
isObjectTypeOrInterface(Type type)
Returns true if the specified type exists in the registry and is an object type or interface
|
boolean |
isPossibleType(Type abstractType,
Type possibleType)
Returns true of the abstract type is in implemented by the object type or interface
|
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)
Removes a
SDLDefinition from the definition list. |
void |
remove(java.lang.String key,
SDLDefinition definition)
Removes a
SDLDefinition from a map. |
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 SchemaParseOrder getParseOrder()
SDLDefinition
s were parsedpublic 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)
SDLDefinition
from the definition list.definition
- the definition to removepublic void remove(java.lang.String key, SDLDefinition definition)
SDLDefinition
from a map.key
- the key to removedefinition
- the definition to removepublic 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.List<SchemaExtensionDefinition> getSchemaExtensionDefinitions()
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 isObjectTypeOrInterface(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<ImplementingTypeDefinition> getAllImplementationsOf(InterfaceTypeDefinition targetInterface)
targetInterface
- the target to search forgetImplementationsOf(InterfaceTypeDefinition)
public java.util.List<ObjectTypeDefinition> getImplementationsOf(InterfaceTypeDefinition targetInterface)
targetInterface
- the target to search forgetAllImplementationsOf(InterfaceTypeDefinition)
public boolean isPossibleType(Type abstractType, Type possibleType)
abstractType
- the abstract type to check (interface or union)possibleType
- the object type or interface to checkpublic boolean isSubTypeOf(Type maybeSubType, Type superType)
maybeSubType
- the type to checksuperType
- the equality checked type