Class SchemaCustomizer
java.lang.Object
org.craftercms.engine.graphql.impl.SchemaCustomizer
Utility class used from Groovy to hold custom fields, fetchers & resolvers
- Since:
- 3.1.4
- Author:
- joseross
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<graphql.schema.GraphQLType>List of additional types to addprotected List<org.craftercms.engine.graphql.impl.SchemaCustomizer.FieldBuilder>List of custom fields to addstatic final graphql.schema.DataFetcher<?>protected List<org.craftercms.engine.graphql.impl.SchemaCustomizer.FetcherBuilder>List of custom fetchers to addprotected List<org.craftercms.engine.graphql.impl.SchemaCustomizer.ResolverBuilder>List of custom resolvers to add -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadditionalTypes(graphql.schema.GraphQLType... types) Adds one or more additional types (needed during runtime but not referenced by any field)protected voidapply(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 & fetchersvoidAdds a custom fetchervoidfield(graphql.schema.GraphQLFieldDefinition.Builder field) Adds a custom field to the root type without a fetcher (for wrapper fields)voidfield(graphql.schema.GraphQLFieldDefinition.Builder field, graphql.schema.DataFetcher<?> fetcher) Adds a custom field to the root typevoidAdds a custom field to a specific type without a fetcher (for wrapper fields)voidfield(String typeName, graphql.schema.GraphQLFieldDefinition.Builder field, graphql.schema.DataFetcher<?> fetcher) Adds a custom field to a specific typeSet<graphql.schema.GraphQLType>Returns the set of additional types to addvoidAdds a custom resolver
-
Field Details
-
EMPTY_DATA_FETCHER
public static final graphql.schema.DataFetcher<?> EMPTY_DATA_FETCHER -
customFields
List of custom fields to add -
fetchers
List of custom fetchers to add -
resolvers
List of custom resolvers to add -
additionalTypes
List of additional types to add
-
-
Constructor Details
-
SchemaCustomizer
public SchemaCustomizer()
-
-
Method Details
-
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
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
Adds a custom fetcher- Parameters:
typeName- the name of the GraphQL typefieldName- the name of the GraphQL fielddataFetcher- the fetcher to use
-
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
Returns the set of additional types to add
-