Class SchemaCustomizer
- java.lang.Object
-
- org.craftercms.engine.graphql.impl.SchemaCustomizer
-
public class SchemaCustomizer extends Object
Utility class used from Groovy to hold custom fields, fetchers & resolvers- Since:
- 3.1.4
- Author:
- joseross
-
-
Field Summary
Fields Modifier and Type Field Description protected List<graphql.schema.GraphQLType>
additionalTypes
List of additional types to addprotected List<org.craftercms.engine.graphql.impl.SchemaCustomizer.FieldBuilder>
customFields
List of custom fields to addstatic graphql.schema.DataFetcher<?>
EMPTY_DATA_FETCHER
protected List<org.craftercms.engine.graphql.impl.SchemaCustomizer.FetcherBuilder>
fetchers
List of custom fetchers to addprotected List<org.craftercms.engine.graphql.impl.SchemaCustomizer.ResolverBuilder>
resolvers
List of custom resolvers to add
-
Constructor Summary
Constructors Constructor Description SchemaCustomizer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
additionalTypes(graphql.schema.GraphQLType... types)
Adds one or more additional types (needed during runtime but not referenced by any field)protected void
apply(String rootTypeName, graphql.schema.GraphQLObjectType.Builder rootTypeBuilder, graphql.schema.GraphQLCodeRegistry.Builder codeRegistry, Map<String,graphql.schema.GraphQLObjectType.Builder> types)
Updates the root type & code registry with the custom fields & fetchersvoid
fetcher(String typeName, String fieldName, graphql.schema.DataFetcher<?> dataFetcher)
Adds a custom fetchervoid
field(graphql.schema.GraphQLFieldDefinition.Builder field)
Adds a custom field to the root type without a fetcher (for wrapper fields)void
field(graphql.schema.GraphQLFieldDefinition.Builder field, graphql.schema.DataFetcher<?> fetcher)
Adds a custom field to the root typevoid
field(String typeName, graphql.schema.GraphQLFieldDefinition.Builder field)
Adds a custom field to a specific type without a fetcher (for wrapper fields)void
field(String typeName, graphql.schema.GraphQLFieldDefinition.Builder field, graphql.schema.DataFetcher<?> fetcher)
Adds a custom field to a specific typeSet<graphql.schema.GraphQLType>
getAdditionalTypes()
Returns the set of additional types to addvoid
resolver(String typeName, graphql.schema.TypeResolver resolver)
Adds a custom resolver
-
-
-
Field Detail
-
EMPTY_DATA_FETCHER
public static final graphql.schema.DataFetcher<?> EMPTY_DATA_FETCHER
-
customFields
protected List<org.craftercms.engine.graphql.impl.SchemaCustomizer.FieldBuilder> customFields
List of custom fields to add
-
fetchers
protected List<org.craftercms.engine.graphql.impl.SchemaCustomizer.FetcherBuilder> fetchers
List of custom fetchers to add
-
resolvers
protected List<org.craftercms.engine.graphql.impl.SchemaCustomizer.ResolverBuilder> resolvers
List of custom resolvers to add
-
additionalTypes
protected List<graphql.schema.GraphQLType> additionalTypes
List of additional types to add
-
-
Method Detail
-
field
public void field(graphql.schema.GraphQLFieldDefinition.Builder field, graphql.schema.DataFetcher<?> fetcher)
Adds a custom field to the root type- Parameters:
field
- the field definitionfetcher
- the fetcher for the field
-
field
public void field(graphql.schema.GraphQLFieldDefinition.Builder field)
Adds a custom field to the root type without a fetcher (for wrapper fields)- Parameters:
field
- the field definition
-
field
public void field(String typeName, graphql.schema.GraphQLFieldDefinition.Builder field, graphql.schema.DataFetcher<?> fetcher)
Adds a custom field to a specific type- Parameters:
typeName
- the name of the typefield
- the field definitionfetcher
- the fetcher for the field
-
field
public void field(String typeName, graphql.schema.GraphQLFieldDefinition.Builder field)
Adds a custom field to a specific type without a fetcher (for wrapper fields)- Parameters:
typeName
- the name of the typefield
- the field definition
-
fetcher
public void fetcher(String typeName, String fieldName, graphql.schema.DataFetcher<?> dataFetcher)
Adds a custom fetcher- Parameters:
typeName
- the name of the GraphQL typefieldName
- the name of the GraphQL fielddataFetcher
- the fetcher to use
-
resolver
public void resolver(String typeName, graphql.schema.TypeResolver resolver)
Adds a custom resolver- Parameters:
typeName
- the name of the GraphQL interfaceresolver
- the resolver to use
-
additionalTypes
public void additionalTypes(graphql.schema.GraphQLType... types)
Adds one or more additional types (needed during runtime but not referenced by any field)- Parameters:
types
- the types to add
-
apply
protected void apply(String rootTypeName, graphql.schema.GraphQLObjectType.Builder rootTypeBuilder, graphql.schema.GraphQLCodeRegistry.Builder codeRegistry, Map<String,graphql.schema.GraphQLObjectType.Builder> types)
Updates the root type & code registry with the custom fields & fetchers- Parameters:
rootTypeName
- the name of the root typerootTypeBuilder
- the root typecodeRegistry
- the code registry
-
getAdditionalTypes
public Set<graphql.schema.GraphQLType> getAdditionalTypes()
Returns the set of additional types to add
-
-