Package graphql.schema
Class GraphQLCodeRegistry
- java.lang.Object
-
- graphql.schema.GraphQLCodeRegistry
-
@PublicApi public class GraphQLCodeRegistry extends java.lang.Object
TheGraphQLCodeRegistry
holds that execution code that is associated with graphql types, namely theDataFetcher
s associated with fields, theTypeResolver
s associated with abstract types and theGraphqlFieldVisibility
For legacy reasons these code functions can still exist on the original type objects but this will be removed in a future version. Once removed the type system objects will be able have proper hashCode/equals methods and be checked for proper equality.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GraphQLCodeRegistry.Builder
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<FieldCoordinates,DataFetcherFactory<?>>
dataFetcherMap
private DataFetcherFactory<?>
defaultDataFetcherFactory
private GraphqlFieldVisibility
fieldVisibility
private java.util.Map<java.lang.String,DataFetcherFactory<?>>
systemDataFetcherMap
private java.util.Map<java.lang.String,TypeResolver>
typeResolverMap
-
Constructor Summary
Constructors Modifier Constructor Description private
GraphQLCodeRegistry(GraphQLCodeRegistry.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DataFetcher<?>
getDataFetcher(FieldCoordinates coordinates, GraphQLFieldDefinition fieldDefinition)
Returns a data fetcher associated with a field located at specified coordinates.DataFetcher<?>
getDataFetcher(GraphQLFieldsContainer parentType, GraphQLFieldDefinition fieldDefinition)
Deprecated.This is confusing becauseGraphQLInterfaceType
s cant have data fetchers.DataFetcher<?>
getDataFetcher(GraphQLObjectType parentType, GraphQLFieldDefinition fieldDefinition)
Returns a data fetcher associated with a field within an object typeprivate static DataFetcher<?>
getDataFetcherImpl(FieldCoordinates coordinates, GraphQLFieldDefinition fieldDefinition, java.util.Map<FieldCoordinates,DataFetcherFactory<?>> dataFetcherMap, java.util.Map<java.lang.String,DataFetcherFactory<?>> systemDataFetcherMap, DataFetcherFactory<?> defaultDataFetcherFactory)
GraphqlFieldVisibility
getFieldVisibility()
TypeResolver
getTypeResolver(GraphQLInterfaceType interfaceType)
Returns the type resolver associated with this interface typeTypeResolver
getTypeResolver(GraphQLUnionType unionType)
Returns the type resolver associated with this union typeprivate static TypeResolver
getTypeResolverForInterface(GraphQLInterfaceType parentType, java.util.Map<java.lang.String,TypeResolver> typeResolverMap)
private static TypeResolver
getTypeResolverForUnion(GraphQLUnionType parentType, java.util.Map<java.lang.String,TypeResolver> typeResolverMap)
boolean
hasDataFetcher(FieldCoordinates coordinates)
Returns true if the code registry contained a data fetcher at the specified co-ordinatesprivate static boolean
hasDataFetcherImpl(FieldCoordinates coords, java.util.Map<FieldCoordinates,DataFetcherFactory<?>> dataFetcherMap, java.util.Map<java.lang.String,DataFetcherFactory<?>> systemDataFetcherMap)
static GraphQLCodeRegistry.Builder
newCodeRegistry()
static GraphQLCodeRegistry.Builder
newCodeRegistry(GraphQLCodeRegistry existingCodeRegistry)
Returns a new builder ofGraphQLCodeRegistry
objects based on the existing oneGraphQLCodeRegistry
transform(java.util.function.Consumer<GraphQLCodeRegistry.Builder> builderConsumer)
This helps you transform the currentGraphQLCodeRegistry
object into another one by starting a builder with all the current values and allows you to transform it how you want.
-
-
-
Field Detail
-
dataFetcherMap
private final java.util.Map<FieldCoordinates,DataFetcherFactory<?>> dataFetcherMap
-
systemDataFetcherMap
private final java.util.Map<java.lang.String,DataFetcherFactory<?>> systemDataFetcherMap
-
typeResolverMap
private final java.util.Map<java.lang.String,TypeResolver> typeResolverMap
-
fieldVisibility
private final GraphqlFieldVisibility fieldVisibility
-
defaultDataFetcherFactory
private final DataFetcherFactory<?> defaultDataFetcherFactory
-
-
Constructor Detail
-
GraphQLCodeRegistry
private GraphQLCodeRegistry(GraphQLCodeRegistry.Builder builder)
-
-
Method Detail
-
getFieldVisibility
public GraphqlFieldVisibility getFieldVisibility()
- Returns:
- the
GraphqlFieldVisibility
-
getDataFetcher
@Deprecated public DataFetcher<?> getDataFetcher(GraphQLFieldsContainer parentType, GraphQLFieldDefinition fieldDefinition)
Deprecated.This is confusing becauseGraphQLInterfaceType
s cant have data fetchers. At runtime only aGraphQLObjectType
can be used to fetch a field. This method allows the mapping to be made, but it is never useful if an interface is passed in.Returns a data fetcher associated with a field within a container type- Parameters:
parentType
- the container typefieldDefinition
- the field definition- Returns:
- the DataFetcher associated with this field. All fields have data fetchers
- See Also:
getDataFetcher(GraphQLObjectType, GraphQLFieldDefinition)
-
getDataFetcher
public DataFetcher<?> getDataFetcher(GraphQLObjectType parentType, GraphQLFieldDefinition fieldDefinition)
Returns a data fetcher associated with a field within an object type- Parameters:
parentType
- the container typefieldDefinition
- the field definition- Returns:
- the DataFetcher associated with this field. All fields have data fetchers
-
getDataFetcher
public DataFetcher<?> getDataFetcher(FieldCoordinates coordinates, GraphQLFieldDefinition fieldDefinition)
Returns a data fetcher associated with a field located at specified coordinates.- Parameters:
coordinates
- the field coordinatesfieldDefinition
- the field definition- Returns:
- the DataFetcher associated with this field. All fields have data fetchers
-
hasDataFetcher
public boolean hasDataFetcher(FieldCoordinates coordinates)
Returns true if the code registry contained a data fetcher at the specified co-ordinates- Parameters:
coordinates
- the field coordinates- Returns:
- the true if there is a data fetcher at those co-ordinates
-
getDataFetcherImpl
private static DataFetcher<?> getDataFetcherImpl(FieldCoordinates coordinates, GraphQLFieldDefinition fieldDefinition, java.util.Map<FieldCoordinates,DataFetcherFactory<?>> dataFetcherMap, java.util.Map<java.lang.String,DataFetcherFactory<?>> systemDataFetcherMap, DataFetcherFactory<?> defaultDataFetcherFactory)
-
hasDataFetcherImpl
private static boolean hasDataFetcherImpl(FieldCoordinates coords, java.util.Map<FieldCoordinates,DataFetcherFactory<?>> dataFetcherMap, java.util.Map<java.lang.String,DataFetcherFactory<?>> systemDataFetcherMap)
-
getTypeResolver
public TypeResolver getTypeResolver(GraphQLInterfaceType interfaceType)
Returns the type resolver associated with this interface type- Parameters:
interfaceType
- the interface type- Returns:
- a non null
TypeResolver
-
getTypeResolver
public TypeResolver getTypeResolver(GraphQLUnionType unionType)
Returns the type resolver associated with this union type- Parameters:
unionType
- the union type- Returns:
- a non null
TypeResolver
-
getTypeResolverForInterface
private static TypeResolver getTypeResolverForInterface(GraphQLInterfaceType parentType, java.util.Map<java.lang.String,TypeResolver> typeResolverMap)
-
getTypeResolverForUnion
private static TypeResolver getTypeResolverForUnion(GraphQLUnionType parentType, java.util.Map<java.lang.String,TypeResolver> typeResolverMap)
-
transform
public GraphQLCodeRegistry transform(java.util.function.Consumer<GraphQLCodeRegistry.Builder> builderConsumer)
This helps you transform the currentGraphQLCodeRegistry
object into another one by starting a builder with all the current values and allows you to transform it how you want.- Parameters:
builderConsumer
- the consumer code that will be given a builder to transform- Returns:
- a new GraphQLCodeRegistry object based on calling build on that builder
-
newCodeRegistry
public static GraphQLCodeRegistry.Builder newCodeRegistry()
- Returns:
- a new builder of
GraphQLCodeRegistry
objects
-
newCodeRegistry
public static GraphQLCodeRegistry.Builder newCodeRegistry(GraphQLCodeRegistry existingCodeRegistry)
Returns a new builder ofGraphQLCodeRegistry
objects based on the existing one- Parameters:
existingCodeRegistry
- the existing code registry to use- Returns:
- a new builder of
GraphQLCodeRegistry
objects
-
-