Package org.apache.sling.graphql.api

# 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`
`NAME_SERVICE_PROPERTY`

## Method Summary

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

## Field Details

### NAME_SERVICE_PROPERTY

static final String NAME_SERVICE_PROPERTY

See Also:
  - Constant Field Values

## 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