Class ExtendedScalars
- java.lang.Object
-
- graphql.scalars.ExtendedScalars
-
@PublicApi public class ExtendedScalars extends java.lang.Object
This is the API entry point for all the extended scalars
-
-
Field Summary
Fields Modifier and Type Field Description static graphql.schema.GraphQLScalarType
AccurateDuration
A duration scalar that accepts string values like `P1DT2H3M4.5s` and produces * `java.time.Duration` objects at runtime.static graphql.schema.GraphQLScalarType
CountryCode
The CountryCode scalar type as defined by ISO 3166-1 alpha-2.static graphql.schema.GraphQLScalarType
Currency
A field whose value is an ISO-4217 currency.static graphql.schema.GraphQLScalarType
Date
An RFC-3339 compliant date scalar that accepts string values like `1996-12-19` and produces `java.time.LocalDate` objects at runtime.static graphql.schema.GraphQLScalarType
DateTime
An RFC-3339 compliant date time scalar that accepts string values like `1996-12-19T16:39:57-08:00` and produces `java.time.OffsetDateTime` objects at runtime.static graphql.schema.GraphQLScalarType
GraphQLBigDecimal
This represents the "BigDecimal" type which is a representation of java.math.BigDecimalstatic graphql.schema.GraphQLScalarType
GraphQLBigInteger
This represents the "BigInteger" type which is a representation of java.math.BigIntegerstatic graphql.schema.GraphQLScalarType
GraphQLByte
This represents the "Byte" type which is a representation of java.lang.Bytestatic graphql.schema.GraphQLScalarType
GraphQLChar
This represents the "Char" type which is a representation of java.lang.Characterstatic graphql.schema.GraphQLScalarType
GraphQLLong
This represents the "Long" type which is a representation of java.lang.Longstatic graphql.schema.GraphQLScalarType
GraphQLShort
This represents the "Short" type which is a representation of java.lang.Shortstatic graphql.schema.GraphQLScalarType
HexColorCode
A field whose value is a hex color code See the Web colors for more details.static graphql.schema.GraphQLScalarType
Json
A synonym class for theObject
scalar, since some people prefer their SDL to look like the following :static graphql.schema.GraphQLScalarType
Locale
A Locale scalar that accepts a IETF BCP 47 language tag string and producesLocale
objects at runtime.static graphql.schema.GraphQLScalarType
LocalTime
A 24-hour local time scalar that accepts strings like `hh:mm:ss` and `hh:mm:ss.sss` and produces `java.time.LocalTime` objects at runtime.static graphql.schema.GraphQLScalarType
NegativeFloat
An `Float` scalar that MUST be less than zerostatic graphql.schema.GraphQLScalarType
NegativeInt
An `Int` scalar that MUST be less than zerostatic graphql.schema.GraphQLScalarType
NominalDuration
An RFC-3339 compliant duration scalar that accepts string values like `P1Y2M3D` and produces `java.time.Period` objects at runtime.static graphql.schema.GraphQLScalarType
NonNegativeFloat
An `Float` scalar that MUST be greater than or equal to zerostatic graphql.schema.GraphQLScalarType
NonNegativeInt
An `Int` scalar that MUST be greater than or equal to zerostatic graphql.schema.GraphQLScalarType
NonPositiveFloat
An `Float` scalar that MUST be less than or equal to zerostatic graphql.schema.GraphQLScalarType
NonPositiveInt
An `Int` scalar that MUST be less than or equal to zerostatic graphql.schema.GraphQLScalarType
Object
An object scalar allows you to have a multi level data value without defining it in the graphql schema.static graphql.schema.GraphQLScalarType
PositiveFloat
An `Float` scalar that MUST be greater than zerostatic graphql.schema.GraphQLScalarType
PositiveInt
An `Int` scalar that MUST be greater than zerostatic graphql.schema.GraphQLScalarType
SecondsSinceEpoch
A scalar that represents a point in time as seconds since the Unix epoch (Unix timestamp).static graphql.schema.GraphQLScalarType
Time
An RFC-3339 compliant time scalar that accepts string values like `6:39:57-08:00` and produces `java.time.OffsetTime` objects at runtime.static graphql.schema.GraphQLScalarType
Url
A URL scalar that accepts URL strings and producesURL
objects at runtimestatic graphql.schema.GraphQLScalarType
UUID
A UUID scalar that accepts a universally unique identifier and producesUUID
objects at runtime.static graphql.schema.GraphQLScalarType
Year
A scalar that represents a year (e.g., `1996`) and produces `java.time.Year` objects at runtime.static graphql.schema.GraphQLScalarType
YearMonth
A scalar that represents a year and month (e.g., `1996-12`) and produces `java.time.YearMonth` objects at runtime.
-
Constructor Summary
Constructors Constructor Description ExtendedScalars()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AliasedScalar.Builder
newAliasedScalar(java.lang.String name)
This allows an existing scalar to be wrapped and aliased with a new name.static RegexScalar.Builder
newRegexScalar(java.lang.String name)
A builder of a scalar that uses one or more regular expressionPattern
s to control the acceptable values for that scalar.
-
-
-
Field Detail
-
DateTime
public static final graphql.schema.GraphQLScalarType DateTime
An RFC-3339 compliant date time scalar that accepts string values like `1996-12-19T16:39:57-08:00` and produces `java.time.OffsetDateTime` objects at runtime.Its
Coercing.serialize(java.lang.Object)
andCoercing.parseValue(java.lang.Object)
methods accept OffsetDateTime, ZoneDateTime and formatted Strings as valid objects.See the rfc3339 spec for more details on the format.
- See Also:
OffsetDateTime
,ZonedDateTime
-
Date
public static final graphql.schema.GraphQLScalarType Date
An RFC-3339 compliant date scalar that accepts string values like `1996-12-19` and produces `java.time.LocalDate` objects at runtime.Its
Coercing.serialize(java.lang.Object)
andCoercing.parseValue(java.lang.Object)
methods accept dateTemporalAccessor
s and formatted Strings as valid objects.See the rfc3339 spec for more details on the format.
- See Also:
LocalDate
-
Time
public static final graphql.schema.GraphQLScalarType Time
An RFC-3339 compliant time scalar that accepts string values like `6:39:57-08:00` and produces `java.time.OffsetTime` objects at runtime.Its
Coercing.serialize(java.lang.Object)
andCoercing.parseValue(java.lang.Object)
methods accept timeTemporalAccessor
s and formatted Strings as valid objects.See the rfc3339 spec for more details on the format.
- See Also:
OffsetTime
-
YearMonth
public static final graphql.schema.GraphQLScalarType YearMonth
A scalar that represents a year and month (e.g., `1996-12`) and produces `java.time.YearMonth` objects at runtime.Its
Coercing.serialize(java.lang.Object)
andCoercing.parseValue(java.lang.Object)
methods accept YearMonth instances and formatted Strings as valid objects.- See Also:
YearMonth
-
Year
public static final graphql.schema.GraphQLScalarType Year
A scalar that represents a year (e.g., `1996`) and produces `java.time.Year` objects at runtime.Its
Coercing.serialize(java.lang.Object)
andCoercing.parseValue(java.lang.Object)
methods accept Year instances and formatted Strings as valid objects.- See Also:
Year
-
LocalTime
public static final graphql.schema.GraphQLScalarType LocalTime
A 24-hour local time scalar that accepts strings like `hh:mm:ss` and `hh:mm:ss.sss` and produces `java.time.LocalTime` objects at runtime.Its
Coercing.serialize(java.lang.Object)
andCoercing.parseValue(java.lang.Object)
methods accept timeTemporalAccessor
s and formatted Strings as valid objects.- See Also:
LocalTime
-
AccurateDuration
public static final graphql.schema.GraphQLScalarType AccurateDuration
A duration scalar that accepts string values like `P1DT2H3M4.5s` and produces * `java.time.Duration` objects at runtime.Components like years and months are not supported as these may have different meanings depending on the placement in the calendar year.
Its
Coercing.serialize(java.lang.Object)
andCoercing.parseValue(java.lang.Object)
methods accept Duration and formatted Strings as valid objects.See the ISO 8601 for more details on the format.
- See Also:
Duration
-
NominalDuration
public static final graphql.schema.GraphQLScalarType NominalDuration
An RFC-3339 compliant duration scalar that accepts string values like `P1Y2M3D` and produces `java.time.Period` objects at runtime.Components like hours and seconds are not supported as these are handled by
AccurateDuration
.Its
Coercing.serialize(java.lang.Object)
andCoercing.parseValue(java.lang.Object)
methods accept Period and formatted Strings as valid objects.See the ISO 8601 for more details on the format.
- See Also:
Period
-
SecondsSinceEpoch
public static final graphql.schema.GraphQLScalarType SecondsSinceEpoch
A scalar that represents a point in time as seconds since the Unix epoch (Unix timestamp).It accepts integers or strings containing integers as input values and produces `java.time.ZonedDateTime` objects at runtime (with UTC timezone).
Its
Coercing.serialize(java.lang.Object)
method accepts variousTemporalAccessor
types and returns the number of seconds since epoch (January 1, 1970, 00:00:00 UTC).Using seconds since epoch is preferable to formatted date time strings in several scenarios:
- When you need a universal representation of a point in time that is timezone-agnostic
- For easier date/time arithmetic and comparison operations
- When storage space or bandwidth efficiency is important (more compact representation)
- To avoid complexities with different date formats and timezone conversions
- For better interoperability with systems that natively work with Unix timestamps
- When working with time-series data or logging systems where timestamps are commonly used
However, human readability is sacrificed compared to formatted date strings, so consider your use case requirements when choosing between
DateTime
andSecondsSinceEpoch
.- See Also:
Instant
,ZonedDateTime
-
Object
public static final graphql.schema.GraphQLScalarType Object
An object scalar allows you to have a multi level data value without defining it in the graphql schema.It might be useful when you have opaque data coming from a backend system that you want to pass on but cant provide the actual graphql schema definition for.
Use this with caution since is breaks one of the key benefits of graphql, which is that a schema describes the shape of the data that can be queried.
This can be declared as follows :
type Customer { name : String backendDetails : Object }
- See Also:
Json
-
Json
public static final graphql.schema.GraphQLScalarType Json
A synonym class for theObject
scalar, since some people prefer their SDL to look like the following :type Customer { name : String backendDetails : JSON }
- See Also:
Object
-
Url
public static final graphql.schema.GraphQLScalarType Url
A URL scalar that accepts URL strings and producesURL
objects at runtime
-
Locale
public static final graphql.schema.GraphQLScalarType Locale
A Locale scalar that accepts a IETF BCP 47 language tag string and producesLocale
objects at runtime.
-
Currency
public static final graphql.schema.GraphQLScalarType Currency
A field whose value is an ISO-4217 currency. See the ISO-4217 for more details.
-
CountryCode
public static final graphql.schema.GraphQLScalarType CountryCode
The CountryCode scalar type as defined by ISO 3166-1 alpha-2. See the ISO 3166-1 alpha-2 for more details.
-
HexColorCode
public static final graphql.schema.GraphQLScalarType HexColorCode
A field whose value is a hex color code See the Web colors for more details.
-
UUID
public static final graphql.schema.GraphQLScalarType UUID
A UUID scalar that accepts a universally unique identifier and producesUUID
objects at runtime.
-
PositiveInt
public static final graphql.schema.GraphQLScalarType PositiveInt
An `Int` scalar that MUST be greater than zero- See Also:
Scalars.GraphQLInt
-
NegativeInt
public static final graphql.schema.GraphQLScalarType NegativeInt
An `Int` scalar that MUST be less than zero- See Also:
Scalars.GraphQLInt
-
NonPositiveInt
public static final graphql.schema.GraphQLScalarType NonPositiveInt
An `Int` scalar that MUST be less than or equal to zero- See Also:
Scalars.GraphQLInt
-
NonNegativeInt
public static final graphql.schema.GraphQLScalarType NonNegativeInt
An `Int` scalar that MUST be greater than or equal to zero- See Also:
Scalars.GraphQLInt
-
PositiveFloat
public static final graphql.schema.GraphQLScalarType PositiveFloat
An `Float` scalar that MUST be greater than zero- See Also:
Scalars.GraphQLFloat
-
NegativeFloat
public static final graphql.schema.GraphQLScalarType NegativeFloat
An `Float` scalar that MUST be less than zero- See Also:
Scalars.GraphQLFloat
-
NonPositiveFloat
public static final graphql.schema.GraphQLScalarType NonPositiveFloat
An `Float` scalar that MUST be less than or equal to zero- See Also:
Scalars.GraphQLFloat
-
NonNegativeFloat
public static final graphql.schema.GraphQLScalarType NonNegativeFloat
An `Float` scalar that MUST be greater than or equal to zero- See Also:
Scalars.GraphQLFloat
-
GraphQLLong
public static final graphql.schema.GraphQLScalarType GraphQLLong
This represents the "Long" type which is a representation of java.lang.Long
-
GraphQLShort
public static final graphql.schema.GraphQLScalarType GraphQLShort
This represents the "Short" type which is a representation of java.lang.Short
-
GraphQLByte
public static final graphql.schema.GraphQLScalarType GraphQLByte
This represents the "Byte" type which is a representation of java.lang.Byte
-
GraphQLBigDecimal
public static final graphql.schema.GraphQLScalarType GraphQLBigDecimal
This represents the "BigDecimal" type which is a representation of java.math.BigDecimal
-
GraphQLBigInteger
public static final graphql.schema.GraphQLScalarType GraphQLBigInteger
This represents the "BigInteger" type which is a representation of java.math.BigInteger
-
GraphQLChar
public static final graphql.schema.GraphQLScalarType GraphQLChar
This represents the "Char" type which is a representation of java.lang.Character
-
-
Method Detail
-
newRegexScalar
public static RegexScalar.Builder newRegexScalar(java.lang.String name)
A builder of a scalar that uses one or more regular expressionPattern
s to control the acceptable values for that scalar.The scalar converts any passed in objects to Strings first and them matches it against the provided scalars to ensure its an acceptable value.
- Parameters:
name
- the name of the scalar- Returns:
- a builder of a regex scalar
-
newAliasedScalar
public static AliasedScalar.Builder newAliasedScalar(java.lang.String name)
This allows an existing scalar to be wrapped and aliased with a new name.For example you may take a `String` scalar and alias it as `SocialMediaLink` if that helps introduce more semantic meaning to your type system.
type Customer { name : String socialMediaLink : SocialMediaLink }
A future version of the graphql specification may add this capability but in the meantime you can use this facility.
- Parameters:
name
- the name of the aliased scalar- Returns:
- a builder of a aliased scalar
-
-