Package graphql.schema
Class GraphQLCodeRegistry.Builder
- java.lang.Object
-
- graphql.schema.GraphQLCodeRegistry.Builder
-
- Enclosing class:
- GraphQLCodeRegistry
public static class GraphQLCodeRegistry.Builder extends java.lang.Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GraphQLCodeRegistry
build()
GraphQLCodeRegistry.Builder
clearDataFetchers()
GraphQLCodeRegistry.Builder
clearTypeResolvers()
GraphQLCodeRegistry.Builder
dataFetcher(FieldCoordinates coordinates, DataFetcher<?> dataFetcher)
Sets the data fetcher for a specific field inside a container typeGraphQLCodeRegistry.Builder
dataFetcher(FieldCoordinates coordinates, DataFetcherFactory<?> dataFetcherFactory)
Sets the data fetcher factory for a specific field inside a container typeGraphQLCodeRegistry.Builder
dataFetcher(GraphQLObjectType parentType, GraphQLFieldDefinition fieldDefinition, DataFetcher<?> dataFetcher)
Sets the data fetcher for a specific field inside an object typeGraphQLCodeRegistry.Builder
dataFetcherIfAbsent(FieldCoordinates coordinates, DataFetcher<?> dataFetcher)
Sets the data fetcher factory for a specific field inside a container type ONLY if not mapping has already been madeGraphQLCodeRegistry.Builder
dataFetchers(GraphQLCodeRegistry codeRegistry)
GraphQLCodeRegistry.Builder
dataFetchers(java.lang.String parentTypeName, java.util.Map<java.lang.String,DataFetcher<?>> fieldDataFetchers)
This allows you you to build all the data fetchers for the fields of a container type.GraphQLCodeRegistry.Builder
defaultDataFetcher(DataFetcherFactory<?> defaultDataFetcherFactory)
This is the default data fetcher factory that will be used for fields that do not have specific data fetchers attached.GraphQLCodeRegistry.Builder
fieldVisibility(GraphqlFieldVisibility fieldVisibility)
DataFetcher<?>
getDataFetcher(FieldCoordinates coordinates, GraphQLFieldDefinition fieldDefinition)
Returns a data fetcher associated with a field located at specified coordinates.DataFetcher<?>
getDataFetcher(GraphQLObjectType parentType, GraphQLFieldDefinition fieldDefinition)
Returns a data fetcher associated with a field within an object typeDataFetcherFactory<?>
getDefaultDataFetcherFactory()
TypeResolver
getTypeResolver(GraphQLInterfaceType interfaceType)
Returns the type resolver associated with this interface typeTypeResolver
getTypeResolver(GraphQLUnionType unionType)
Returns the type resolver associated with this union typeboolean
hasChanged()
boolean
hasDataFetcher(FieldCoordinates coordinates)
Returns true if the code registry contained a data fetcher at the specified co-ordinatesboolean
hasTypeResolver(java.lang.String typeName)
Returns true of a type resolver has been registered for this type nameGraphQLCodeRegistry.Builder
systemDataFetcher(FieldCoordinates coordinates, DataFetcher<?> dataFetcher)
Called to place system data fetchers (eg Introspection fields) into the mixGraphQLCodeRegistry.Builder
trackChanges()
A helper method to track if the builder changes from the point at which this method was called.GraphQLCodeRegistry.Builder
typeResolver(GraphQLInterfaceType interfaceType, TypeResolver typeResolver)
GraphQLCodeRegistry.Builder
typeResolver(GraphQLUnionType unionType, TypeResolver typeResolver)
GraphQLCodeRegistry.Builder
typeResolver(java.lang.String typeName, TypeResolver typeResolver)
GraphQLCodeRegistry.Builder
typeResolverIfAbsent(GraphQLInterfaceType interfaceType, TypeResolver typeResolver)
GraphQLCodeRegistry.Builder
typeResolverIfAbsent(GraphQLUnionType unionType, TypeResolver typeResolver)
GraphQLCodeRegistry.Builder
typeResolvers(GraphQLCodeRegistry codeRegistry)
-
-
-
Method Detail
-
trackChanges
public GraphQLCodeRegistry.Builder trackChanges()
A helper method to track if the builder changes from the point at which this method was called.- Returns:
- this builder for fluent code
-
hasChanged
public boolean hasChanged()
- Returns:
- true if the builder has changed since
trackChanges()
was called
-
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
-
getDefaultDataFetcherFactory
public DataFetcherFactory<?> getDefaultDataFetcherFactory()
- Returns:
- the default data fetcher factory associated with this code registry
-
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
-
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
-
hasTypeResolver
public boolean hasTypeResolver(java.lang.String typeName)
Returns true of a type resolver has been registered for this type name- Parameters:
typeName
- the name to check- Returns:
- true if there is already a type resolver
-
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
-
dataFetcher
public GraphQLCodeRegistry.Builder dataFetcher(FieldCoordinates coordinates, DataFetcher<?> dataFetcher)
Sets the data fetcher for a specific field inside a container type- Parameters:
coordinates
- the field coordinatesdataFetcher
- the data fetcher code for that field- Returns:
- this builder
-
dataFetcher
public GraphQLCodeRegistry.Builder dataFetcher(GraphQLObjectType parentType, GraphQLFieldDefinition fieldDefinition, DataFetcher<?> dataFetcher)
Sets the data fetcher for a specific field inside an object type- Parameters:
parentType
- the object typefieldDefinition
- the field definitiondataFetcher
- the data fetcher code for that field- Returns:
- this builder
-
systemDataFetcher
public GraphQLCodeRegistry.Builder systemDataFetcher(FieldCoordinates coordinates, DataFetcher<?> dataFetcher)
Called to place system data fetchers (eg Introspection fields) into the mix- Parameters:
coordinates
- the field coordinatesdataFetcher
- the data fetcher code for that field- Returns:
- this builder
-
dataFetcher
public GraphQLCodeRegistry.Builder dataFetcher(FieldCoordinates coordinates, DataFetcherFactory<?> dataFetcherFactory)
Sets the data fetcher factory for a specific field inside a container type- Parameters:
coordinates
- the field coordinatesdataFetcherFactory
- the data fetcher factory code for that field- Returns:
- this builder
-
dataFetcherIfAbsent
public GraphQLCodeRegistry.Builder dataFetcherIfAbsent(FieldCoordinates coordinates, DataFetcher<?> dataFetcher)
Sets the data fetcher factory for a specific field inside a container type ONLY if not mapping has already been made- Parameters:
coordinates
- the field coordinatesdataFetcher
- the data fetcher code for that field- Returns:
- this builder
-
dataFetchers
public GraphQLCodeRegistry.Builder dataFetchers(java.lang.String parentTypeName, java.util.Map<java.lang.String,DataFetcher<?>> fieldDataFetchers)
This allows you you to build all the data fetchers for the fields of a container type.- Parameters:
parentTypeName
- the parent container typefieldDataFetchers
- the map of field names to data fetchers- Returns:
- this builder
-
defaultDataFetcher
public GraphQLCodeRegistry.Builder defaultDataFetcher(DataFetcherFactory<?> defaultDataFetcherFactory)
This is the default data fetcher factory that will be used for fields that do not have specific data fetchers attached. By defaultPropertyDataFetcher
is used but you can have your own default via this method.- Parameters:
defaultDataFetcherFactory
- the default data fetcher factory used- Returns:
- this builder
-
dataFetchers
public GraphQLCodeRegistry.Builder dataFetchers(GraphQLCodeRegistry codeRegistry)
-
typeResolver
public GraphQLCodeRegistry.Builder typeResolver(GraphQLInterfaceType interfaceType, TypeResolver typeResolver)
-
typeResolverIfAbsent
public GraphQLCodeRegistry.Builder typeResolverIfAbsent(GraphQLInterfaceType interfaceType, TypeResolver typeResolver)
-
typeResolver
public GraphQLCodeRegistry.Builder typeResolver(GraphQLUnionType unionType, TypeResolver typeResolver)
-
typeResolverIfAbsent
public GraphQLCodeRegistry.Builder typeResolverIfAbsent(GraphQLUnionType unionType, TypeResolver typeResolver)
-
typeResolver
public GraphQLCodeRegistry.Builder typeResolver(java.lang.String typeName, TypeResolver typeResolver)
-
typeResolvers
public GraphQLCodeRegistry.Builder typeResolvers(GraphQLCodeRegistry codeRegistry)
-
fieldVisibility
public GraphQLCodeRegistry.Builder fieldVisibility(GraphqlFieldVisibility fieldVisibility)
-
clearDataFetchers
public GraphQLCodeRegistry.Builder clearDataFetchers()
-
clearTypeResolvers
public GraphQLCodeRegistry.Builder clearTypeResolvers()
-
build
public GraphQLCodeRegistry build()
-
-