Package graphql.schema.idl
Class TypeDefinitionRegistry
java.lang.Object
graphql.schema.idl.TypeDefinitionRegistry
- All Implemented Interfaces:
Serializable
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 TypeFieldDescriptionprivate final Map<String, DirectiveDefinition> private final Map<String, List<EnumTypeExtensionDefinition>> private final Map<String, List<InputObjectTypeExtensionDefinition>> private final Map<String, List<InterfaceTypeExtensionDefinition>> private final Map<String, List<ObjectTypeExtensionDefinition>> private final Map<String, List<ScalarTypeExtensionDefinition>> private final Map<String, ScalarTypeDefinition> private SchemaDefinitionprivate final List<SchemaExtensionDefinition> private final SchemaParseOrderprivate final Map<String, TypeDefinition> private final Map<String, List<UnionTypeExtensionDefinition>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(SDLDefinition definition) Adds a definition to the registryaddAll(Collection<SDLDefinition> definitions) Adds a a collections of definitions to the registryprivate Optional<GraphQLError> private Map<String, OperationTypeDefinition> checkMergeSchemaDefs(TypeDefinitionRegistry toBeMergedTypeRegistry, List<GraphQLError> errors) private <T extends TypeDefinition>
Optional<GraphQLError> private <T extends TypeDefinition>
Optional<GraphQLError> getAllImplementationsOf(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 type<T extends TypeDefinition>
Optional<T> <T extends TypeDefinition>
Optional<T> <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 nameprivate GraphQLErrorhandleReDefinition(DirectiveDefinition oldEntry, DirectiveDefinition newEntry) private GraphQLErrorhandleReDefinition(TypeDefinition oldEntry, TypeDefinition newEntry) booleanbooleanisInterfaceOrUnion(Type type) Returns true if the specified type exists in the registry and is an abstract (Interface or Union) typebooleanisObjectType(Type type) Returns true if the specified type exists in the registry and is an object typebooleanisObjectTypeOrInterface(Type type) Returns true if the specified type exists in the registry and is an object type or interfacebooleanisPossibleType(Type abstractType, Type possibleType) Returns true of the abstract type is in implemented by the object type or interfacebooleanisSubTypeOf(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 onevoidremove(SDLDefinition definition) Removes aSDLDefinitionfrom the definition list.voidremove(String key, SDLDefinition definition) Removes aSDLDefinitionfrom a map.private voidremoveFromList(Map source, TypeDefinition value) private voidremoveFromMap(Map source, String key) scalars()types()
-
Field Details
-
objectTypeExtensions
-
interfaceTypeExtensions
-
unionTypeExtensions
-
enumTypeExtensions
-
scalarTypeExtensions
-
inputObjectTypeExtensions
-
types
-
scalarTypes
-
directiveDefinitions
-
schema
-
schemaExtensionDefinitions
-
schemaParseOrder
-
-
Constructor Details
-
TypeDefinitionRegistry
public TypeDefinitionRegistry()
-
-
Method Details
-
getParseOrder
- Returns:
- the order in which
SDLDefinitions 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
-
checkMergeSchemaDefs
private Map<String,OperationTypeDefinition> checkMergeSchemaDefs(TypeDefinitionRegistry toBeMergedTypeRegistry, List<GraphQLError> errors) -
checkAddOperationDefs
-
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 aSDLDefinitionfrom the definition list.- Parameters:
definition- the definition to remove
-
removeFromList
-
remove
Removes aSDLDefinitionfrom a map.- Parameters:
key- the key to removedefinition- the definition to remove
-
removeFromMap
-
define
private <T extends TypeDefinition> Optional<GraphQLError> define(Map<String, T> source, Map<String, T> target, T newEntry) -
define
private <T extends DirectiveDefinition> Optional<GraphQLError> define(Map<String, T> source, Map<String, T> target, T newEntry) -
defineExt
private <T extends TypeDefinition> Optional<GraphQLError> defineExt(Map<String, List<T>> typeExtensions, T newEntry, Function<T, String> namerFunc) -
types
-
scalars
-
objectTypeExtensions
-
interfaceTypeExtensions
-
unionTypeExtensions
-
enumTypeExtensions
-
scalarTypeExtensions
-
inputObjectTypeExtensions
-
schemaDefinition
-
getSchemaExtensionDefinitions
-
handleReDefinition
-
handleReDefinition
-
getDirectiveDefinition
-
getDirectiveDefinitions
-
hasType
-
getType
-
getType
-
getType
-
getType
-
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
-