Package graphql.schema
Class ShallowTypeRefCollector
java.lang.Object
graphql.schema.ShallowTypeRefCollector
Collects type-refs found in type- and directive-definitions for later replacement with actual types.
This class performs shallow scans (no recursive traversal from one type-def to another) and
collects replacement targets that need their type references resolved.
Also tracks interface-to-implementation relationships.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns an immutable map of interface names to sorted lists of implementing object type names.voidhandleDirective(GraphQLDirective directive) Scan a directive definition for type references in its arguments.voidScan a type definition for type references.voidreplaceTypes(Map<String, GraphQLNamedType> typeMap) Replace all collected type references with actual types from typeMap.voidscanAppliedDirectives(List<GraphQLAppliedDirective> appliedDirectives) Scan applied directives for type references in their arguments.
-
Constructor Details
-
ShallowTypeRefCollector
public ShallowTypeRefCollector()
-
-
Method Details
-
handleTypeDef
Scan a type definition for type references. Called on GraphQL{Object|Input|Scalar|Union|etc}Type - NOT on wrappers or type-refs.- Parameters:
type- the named type to scan
-
scanAppliedDirectives
Scan applied directives for type references in their arguments.- Parameters:
appliedDirectives- the applied directives to scan
-
handleDirective
Scan a directive definition for type references in its arguments.- Parameters:
directive- the directive definition to scan
-
replaceTypes
Replace all collected type references with actual types from typeMap. After this call, no GraphQLTypeReference should remain in the schema.Important: This method mutates the type objects that were scanned via
handleTypeDef(GraphQLNamedType)andhandleDirective(GraphQLDirective). The same type instances cannot be reused to build another schema after this method has been called. If you need to build multiple schemas with the same types, you must create new type instances for each schema.- Parameters:
typeMap- the map of type names to actual types- Throws:
AssertException- if a referenced type is not found in typeMap
-
getInterfaceNameToObjectTypeNames
public com.google.common.collect.ImmutableMap<String,com.google.common.collect.ImmutableList<String>> getInterfaceNameToObjectTypeNames()Returns an immutable map of interface names to sorted lists of implementing object type names. The object type names are maintained in sorted order as they're added.- Returns:
- immutable map from interface name to list of object type names
-