Package graphql.schema.idl
Class TypeDefinitionRegistry
java.lang.Object
graphql.schema.idl.TypeDefinitionRegistry
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ImmutableTypeDefinitionRegistry
A
TypeDefinitionRegistry
contains the set of type definitions that come from compiling
a graphql schema definition file via SchemaParser.parse(String)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map
<String, DirectiveDefinition> protected final Map
<String, List<EnumTypeExtensionDefinition>> protected final Map
<String, List<InputObjectTypeExtensionDefinition>> protected final Map
<String, List<InterfaceTypeExtensionDefinition>> protected final Map
<String, List<ObjectTypeExtensionDefinition>> protected final Map
<String, List<ScalarTypeExtensionDefinition>> protected final Map
<String, ScalarTypeDefinition> protected @Nullable SchemaDefinition
protected final List
<SchemaExtensionDefinition> protected final SchemaParseOrder
protected final Map
<String, TypeDefinition> protected final Map
<String, List<UnionTypeExtensionDefinition>> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
TypeDefinitionRegistry
(Map<String, List<ObjectTypeExtensionDefinition>> objectTypeExtensions, Map<String, List<InterfaceTypeExtensionDefinition>> interfaceTypeExtensions, Map<String, List<UnionTypeExtensionDefinition>> unionTypeExtensions, Map<String, List<EnumTypeExtensionDefinition>> enumTypeExtensions, Map<String, List<ScalarTypeExtensionDefinition>> scalarTypeExtensions, Map<String, List<InputObjectTypeExtensionDefinition>> inputObjectTypeExtensions, Map<String, TypeDefinition> types, Map<String, ScalarTypeDefinition> scalarTypes, Map<String, DirectiveDefinition> directiveDefinitions, List<SchemaExtensionDefinition> schemaExtensionDefinitions, @Nullable SchemaDefinition schema, SchemaParseOrder schemaParseOrder) -
Method Summary
Modifier and TypeMethodDescriptionadd
(SDLDefinition definition) Adds a definition to the registryaddAll
(Collection<SDLDefinition> definitions) Adds a a collections of definitions to the registrygetAllImplementationsOf
(InterfaceTypeDefinition targetInterface) Returns the list of object and interface types that implement the given interface typegetDirectiveDefinition
(String directiveName) getImplementationsOf
(InterfaceTypeDefinition targetInterface) Returns the list of object interface types that implement the given interface typeDeprecated.<T extends TypeDefinition>
Optional<T> Deprecated.use thegetTypeOrNull(Type)
variants instead since they avoid the allocation of an optional objectDeprecated.use thegetTypeOrNull(Type)
variants instead since they avoid the allocation of an optional object<T extends TypeDefinition>
Optional<T> Deprecated.use thegetTypeOrNull(Type)
variants instead since they avoid the allocation of an optional object@Nullable TypeDefinition
getTypeOrNull
(Type type) Returns aTypeDefinition
of the specified type or null<T extends TypeDefinition>
@Nullable TgetTypeOrNull
(Type type, Class<T> ofType) Returns aTypeDefinition
of the specified type with the specified class or null@Nullable TypeDefinition
getTypeOrNull
(String typeName) Returns aTypeDefinition
of the specified name or null<T extends TypeDefinition>
@Nullable TgetTypeOrNull
(String typeName, Class<T> ofType) Returns aTypeDefinition
of the specified name and class or null<T extends TypeDefinition>
List<T> Returns a list of types in the registry of that specified class<T extends TypeDefinition>
Map<String, T> getTypesMap
(Class<T> targetClass) Returns a map of types in the registry of that specified class keyed by nameboolean
Returns true if the registry has a type of the specifiedTypeName
boolean
Returns true if the registry has a type of the specified nameboolean
isInterfaceOrUnion
(Type type) Returns true if the specified type exists in the registry and is an abstract (Interface or Union) typeboolean
isObjectType
(Type type) Returns true if the specified type exists in the registry and is an object typeboolean
isObjectTypeOrInterface
(Type type) Returns true if the specified type exists in the registry and is an object type or interfaceboolean
isPossibleType
(Type abstractType, Type possibleType) Returns true of the abstract type is in implemented by the object type or interfaceboolean
isSubTypeOf
(Type maybeSubType, Type superType) Returns true if the maybe type is either equal or a subset of the second super type (covariant).merge
(TypeDefinitionRegistry typeRegistry) This will merge these type registries together and return this onereadOnly()
void
remove
(SDLDefinition definition) Removes aSDLDefinition
from the definition list.void
remove
(String key, SDLDefinition definition) Removes aSDLDefinition
from a map.scalars()
types()
-
Field Details
-
objectTypeExtensions
-
interfaceTypeExtensions
-
unionTypeExtensions
-
enumTypeExtensions
-
scalarTypeExtensions
-
inputObjectTypeExtensions
-
types
-
scalarTypes
-
directiveDefinitions
-
schema
-
schemaExtensionDefinitions
-
schemaParseOrder
-
-
Constructor Details
-
TypeDefinitionRegistry
public TypeDefinitionRegistry() -
TypeDefinitionRegistry
protected TypeDefinitionRegistry(Map<String, List<ObjectTypeExtensionDefinition>> objectTypeExtensions, Map<String, List<InterfaceTypeExtensionDefinition>> interfaceTypeExtensions, Map<String, List<UnionTypeExtensionDefinition>> unionTypeExtensions, Map<String, List<EnumTypeExtensionDefinition>> enumTypeExtensions, Map<String, List<ScalarTypeExtensionDefinition>> scalarTypeExtensions, Map<String, List<InputObjectTypeExtensionDefinition>> inputObjectTypeExtensions, Map<String, TypeDefinition> types, Map<String, ScalarTypeDefinition> scalarTypes, Map<String, DirectiveDefinition> directiveDefinitions, List<SchemaExtensionDefinition> schemaExtensionDefinitions, @Nullable SchemaDefinition schema, SchemaParseOrder schemaParseOrder)
-
-
Method Details
-
readOnly
- Returns:
- an immutable view of this
TypeDefinitionRegistry
that is more performant when in read only mode.
-
getParseOrder
- Returns:
- the order in which
SDLDefinition
s were parsed
-
merge
This will merge these type registries together and return this one- Parameters:
typeRegistry
- the registry to be merged into this one- Returns:
- this registry
- Throws:
SchemaProblem
- if there are problems merging the types such as redefinitions
-
addAll
Adds a a collections of definitions to the registry- Parameters:
definitions
- the definitions to add- Returns:
- an optional error for the first problem, typically type redefinition
-
add
Adds a definition to the registry- Parameters:
definition
- the definition to add- Returns:
- an optional error
-
remove
Removes aSDLDefinition
from the definition list.- Parameters:
definition
- the definition to remove
-
remove
Removes aSDLDefinition
from a map.- Parameters:
key
- the key to removedefinition
- the definition to remove
-
types
-
scalars
-
objectTypeExtensions
-
interfaceTypeExtensions
-
unionTypeExtensions
-
enumTypeExtensions
-
scalarTypeExtensions
-
inputObjectTypeExtensions
-
schemaDefinition
-
getSchemaExtensionDefinitions
-
getDirectiveDefinition
-
getDirectiveDefinitions
-
hasType
Returns true if the registry has a type of the specifiedTypeName
- Parameters:
typeName
- the type name to check- Returns:
- true if the registry has a type by that type name
-
hasType
Returns true if the registry has a type of the specified name- Parameters:
name
- the name to check- Returns:
- true if the registry has a type by that name
-
getType
Deprecated.use thegetTypeOrNull(Type)
variants instead since they avoid the allocation of an optional objectReturns an optionalTypeDefinition
of the specified type orOptional.empty()
- Parameters:
type
- the type to check- Returns:
- an optional
TypeDefinition
or empty if it's not found
-
getType
@Deprecated(since="2025-07-7") public <T extends TypeDefinition> Optional<T> getType(Type type, Class<T> ofType) Deprecated.use thegetTypeOrNull(Type)
variants instead since they avoid the allocation of an optional objectReturns an optionalTypeDefinition
of the specified type with the specified class orOptional.empty()
- Parameters:
type
- the type to checkofType
- the class ofTypeDefinition
- Returns:
- an optional
TypeDefinition
or empty if it's not found
-
getType
Deprecated.use thegetTypeOrNull(Type)
variants instead since they avoid the allocation of an optional objectReturns an optionalTypeDefinition
of the specified type name orOptional.empty()
- Parameters:
typeName
- the type to check- Returns:
- an optional
TypeDefinition
or empty if it's not found
-
getType
@Deprecated(since="2025-07-7") public <T extends TypeDefinition> Optional<T> getType(String typeName, Class<T> ofType) Deprecated.use thegetTypeOrNull(Type)
variants instead since they avoid the allocation of an optional objectReturns an optionalTypeDefinition
of the specified type name with the specified class orOptional.empty()
- Parameters:
typeName
- the type to checkofType
- the class ofTypeDefinition
-
getTypeOrNull
Returns aTypeDefinition
of the specified type or null- Parameters:
type
- the type to check- Returns:
- a
TypeDefinition
or null if it's not found
-
getTypeOrNull
Returns aTypeDefinition
of the specified type with the specified class or null- Parameters:
type
- the type to checkofType
- the class ofTypeDefinition
- Returns:
- a
TypeDefinition
or null if it's not found
-
getTypeOrNull
Returns aTypeDefinition
of the specified name or null- Parameters:
typeName
- the type name to check- Returns:
- a
TypeDefinition
or null if it's not found
-
getTypeOrNull
Returns aTypeDefinition
of the specified name and class or null- Parameters:
typeName
- the type name to checkofType
- the class ofTypeDefinition
- Returns:
- a
TypeDefinition
or null if it's not found
-
isInterfaceOrUnion
Returns true if the specified type exists in the registry and is an abstract (Interface or Union) type- Parameters:
type
- the type to check- Returns:
- true if its abstract
-
isObjectTypeOrInterface
Returns true if the specified type exists in the registry and is an object type or interface- Parameters:
type
- the type to check- Returns:
- true if its an object type or interface
-
isObjectType
Returns true if the specified type exists in the registry and is an object type- Parameters:
type
- the type to check- Returns:
- true if its an object type
-
getTypes
Returns a list of types in the registry of that specified class- Type Parameters:
T
- must extend TypeDefinition- Parameters:
targetClass
- the class to search for- Returns:
- a list of types of the target class
-
getTypesMap
Returns a map of types in the registry of that specified class keyed by name- Type Parameters:
T
- must extend TypeDefinition- Parameters:
targetClass
- the class to search for- Returns:
- a map of types
-
getAllImplementationsOf
public List<ImplementingTypeDefinition> getAllImplementationsOf(InterfaceTypeDefinition targetInterface) Returns the list of object and interface types that implement the given interface type- Parameters:
targetInterface
- the target to search for- Returns:
- the list of object types that implement the given interface type
- See Also:
-
getImplementationsOf
Returns the list of object interface types that implement the given interface type- Parameters:
targetInterface
- the target to search for- Returns:
- the list of object types that implement the given interface type
- See Also:
-
isPossibleType
Returns true of the abstract type is in implemented by the object type or interface- Parameters:
abstractType
- the abstract type to check (interface or union)possibleType
- the object type or interface to check- Returns:
- true if the object type or interface implements the abstract type
-
isSubTypeOf
Returns true if the maybe type is either equal or a subset of the second super type (covariant).- Parameters:
maybeSubType
- the type to checksuperType
- the equality checked type- Returns:
- true if maybeSubType is covariant or equal to superType
-
getTypeOrNull(Type)
variants instead since they avoid the allocation of an optional object