Class CustomScalarRegistryImpl

java.lang.Object
com.graphql_java_generator.customscalars.CustomScalarRegistryImpl
All Implemented Interfaces:
CustomScalarRegistry

@Component public class CustomScalarRegistryImpl extends Object implements CustomScalarRegistry
Author:
etienne-sf
  • Constructor Details

    • CustomScalarRegistryImpl

      public CustomScalarRegistryImpl()
  • Method Details

    • registerGraphQLScalarType

      public void registerGraphQLScalarType(String typeName, graphql.schema.GraphQLScalarType type, Class<?> valueClazz)
      Description copied from interface: CustomScalarRegistry
      Manually register one GraphQLScalarType.
      Specified by:
      registerGraphQLScalarType in interface CustomScalarRegistry
      Parameters:
      typeName - The name of the custom scalar type, as defined in the provided GaphQL schema. It may be different from the provided graphQLScalarType
      type - The GraphQL custom scalar class, that contain the coercing rules to serialize and unserialize this custom scalar
      valueClazz - The java The java type that will contain values for this custom scalar. This is needed to properly create the data from the value read in a string, especially when reading a GraphQL request, when in client mode
    • getGraphQLCustomScalarType

      public graphql.schema.GraphQLScalarType getGraphQLCustomScalarType(String graphQLTypeName)
      Description copied from interface: CustomScalarRegistry
      Retrieves the registered GraphQLScalarType for this GraphQL CustomScalar.
      Specified by:
      getGraphQLCustomScalarType in interface CustomScalarRegistry
      Returns:
      the GraphQLScalarType, or null if no converter has been registered for the given name
    • getCustomScalar

      public CustomScalar getCustomScalar(String graphQLTypeName)
      Description copied from interface: CustomScalarRegistry
      Retrieves the registered GraphQLScalarType for this GraphQL CustomScalar.
      Specified by:
      getCustomScalar in interface CustomScalarRegistry
      Returns:
      the GraphQLScalarType, or null if no converter has been registered for the given name
    • isCustomScalarRegistryInitialized

      public static boolean isCustomScalarRegistryInitialized(String schema)
      Indicates whether the CustomScalarRegistry for the given schema has been initialized.
      Parameters:
      schema - value of the springBeanSuffix plugin parameter for the searched schema. When there is only one schema, this plugin parameter is usually not set. In this case, its default value ("") is used.
      Returns:
      true if this registry is already initialized
      Throws:
      IllegalArgumentException - If no CustomScalarRegistry has been defined for the given schema
    • getCustomScalarRegistry

      public static CustomScalarRegistry getCustomScalarRegistry(String schema)
      Retrieves the CustomScalarRegistry for the given schema. This registry is initialized in the generated class CustomScalarRegistryInitializer.
      Note: this method is an internal utility method.
      Parameters:
      schema - value of the springBeanSuffix plugin parameter for the searched schema. When there is only one schema, this plugin parameter is usually not set. In this case, its default value ("") is used.
      Returns:
      Throws:
      IllegalArgumentException - If no CustomScalarRegistry has been defined for the given schema
    • setCustomScalarRegistry

      public static void setCustomScalarRegistry(String schema, CustomScalarRegistry customScalarRegistry)
      Sets the CustomScalarRegistry for the given schema. This method should only be called from the generated class CustomScalarRegistryInitializer.
      Note: this method is an internal utility method.
      Parameters:
      schema - value of the springBeanSuffix plugin parameter for the searched schema. When there is only one schema, this plugin parameter is usually not set. In this case, its default value ("") is used.
      customScalarRegistry - The CustomScalarRegistry associated with this schema