@PublicApi public class TypeDefinitionRegistry extends 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 |
---|---|
Optional<GraphQLError> |
add(SDLDefinition definition)
Adds a definition to the registry
|
Optional<GraphQLError> |
addAll(Collection<SDLDefinition> definitions)
Adds a a collections of definitions to the registry
|
Map<String,List<EnumTypeExtensionDefinition>> |
enumTypeExtensions() |
Optional<DirectiveDefinition> |
getDirectiveDefinition(String directiveName) |
Map<String,DirectiveDefinition> |
getDirectiveDefinitions() |
List<ObjectTypeDefinition> |
getImplementationsOf(InterfaceTypeDefinition targetInterface)
Returns the list of object types that implement the given interface type
|
Optional<TypeDefinition> |
getType(String typeName) |
<T extends TypeDefinition> |
getType(String typeName,
Class<T> ofType) |
Optional<TypeDefinition> |
getType(Type type) |
<T extends TypeDefinition> |
getType(Type type,
Class<T> ofType) |
<T extends TypeDefinition> |
getTypes(Class<T> targetClass)
Returns a list of types in the registry of that specified class
|
<T extends TypeDefinition> |
getTypesMap(Class<T> targetClass)
Returns a map of types in the registry of that specified class keyed by name
|
boolean |
hasType(TypeName typeName) |
Map<String,List<InputObjectTypeExtensionDefinition>> |
inputObjectTypeExtensions() |
Map<String,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
|
Map<String,List<ObjectTypeExtensionDefinition>> |
objectTypeExtensions() |
void |
remove(SDLDefinition definition) |
Map<String,ScalarTypeDefinition> |
scalars() |
Map<String,List<ScalarTypeExtensionDefinition>> |
scalarTypeExtensions() |
Optional<SchemaDefinition> |
schemaDefinition() |
Map<String,TypeDefinition> |
types() |
Map<String,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 Optional<GraphQLError> addAll(Collection<SDLDefinition> definitions)
definitions
- the definitions to addpublic Optional<GraphQLError> add(SDLDefinition definition)
definition
- the definition to addpublic void remove(SDLDefinition definition)
public Map<String,TypeDefinition> types()
public Map<String,ScalarTypeDefinition> scalars()
public Map<String,List<ObjectTypeExtensionDefinition>> objectTypeExtensions()
public Map<String,List<InterfaceTypeExtensionDefinition>> interfaceTypeExtensions()
public Map<String,List<UnionTypeExtensionDefinition>> unionTypeExtensions()
public Map<String,List<EnumTypeExtensionDefinition>> enumTypeExtensions()
public Map<String,List<ScalarTypeExtensionDefinition>> scalarTypeExtensions()
public Map<String,List<InputObjectTypeExtensionDefinition>> inputObjectTypeExtensions()
public Optional<SchemaDefinition> schemaDefinition()
public Optional<DirectiveDefinition> getDirectiveDefinition(String directiveName)
public Map<String,DirectiveDefinition> getDirectiveDefinitions()
public boolean hasType(TypeName typeName)
public Optional<TypeDefinition> getType(Type type)
public <T extends TypeDefinition> Optional<T> getType(Type type, Class<T> ofType)
public Optional<TypeDefinition> getType(String typeName)
public <T extends TypeDefinition> Optional<T> getType(String typeName, 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> List<T> getTypes(Class<T> targetClass)
T
- must extend TypeDefinitiontargetClass
- the class to search forpublic <T extends TypeDefinition> Map<String,T> getTypesMap(Class<T> targetClass)
T
- must extend TypeDefinitiontargetClass
- the class to search forpublic 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 typeCopyright © 2019. All rights reserved.