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>
    List of additional types to add
    protected List<org.craftercms.engine.graphql.impl.SchemaCustomizer.FieldBuilder>
    List of custom fields to add
    static final graphql.schema.DataFetcher<?>
     
    protected List<org.craftercms.engine.graphql.impl.SchemaCustomizer.FetcherBuilder>
    List of custom fetchers to add
    protected List<org.craftercms.engine.graphql.impl.SchemaCustomizer.ResolverBuilder>
    List of custom resolvers to add
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    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 & fetchers
    void
    fetcher(String typeName, String fieldName, graphql.schema.DataFetcher<?> dataFetcher)
    Adds a custom fetcher
    void
    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 type
    void
    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 type
    Set<graphql.schema.GraphQLType>
    Returns the set of additional types to add
    void
    resolver(String typeName, graphql.schema.TypeResolver resolver)
    Adds a custom resolver

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • 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
  • 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 definition
      fetcher - 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 type
      field - the field definition
      fetcher - 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 type
      field - 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 type
      fieldName - the name of the GraphQL field
      dataFetcher - 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 interface
      resolver - 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 type
      rootTypeBuilder - the root type
      codeRegistry - the code registry
    • getAdditionalTypes

      public Set<graphql.schema.GraphQLType> getAdditionalTypes()
      Returns the set of additional types to add