Interface SlingScalarConverter<T,X>


@ConsumerType public interface SlingScalarConverter<T,X>
A service that parses and serializes a custom GraphQL Scalar by converting between an eXternal type X an an inTernal one T. Instances of this service must have a NAME_SERVICE_PROPERTY service property which is the name of the scalar type.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    parseValue(X input)
    Parse an external value (a query argument for example) into its internal representation
    serialize(T value)
    Serialize an internal value (provided by a SlingDataFetcher into its external representation.
  • Field Details

  • Method Details

    • parseValue

      @Nullable T parseValue(@Nullable X input) throws ScalarConversionException
      Parse an external value (a query argument for example) into its internal representation
      Parameters:
      input - the external value to parse
      Returns:
      the internal representation of the passed input
      Throws:
      ScalarConversionException - if the parsing operation fails
    • serialize

      @Nullable X serialize(@Nullable T value) throws ScalarConversionException
      Serialize an internal value (provided by a SlingDataFetcher into its external representation.
      Parameters:
      value - the internal value
      Returns:
      the external representation of the internal value
      Throws:
      ScalarConversionException - if the serialization operation fails