View Source Absinthe.Type.Scalar (absinthe v1.7.0)
Represents a primitive value.
GraphQL responses take the form of a hierarchical tree; the leaves on these trees are scalars.
Also see Absinthe.Type.Object.
Built-In Scalars
The following built-in scalar types are defined:
:boolean- Representstrueorfalse. See the GraphQL Specification.:float- Represents signed double‐precision fractional values as specified by IEEE 754. See the GraphQL Specification.:id- Represents a unique identifier, often used to refetch an object or as key for a cache. The ID type is serialized in the same way as a String; however, it is not intended to be human‐readable. See the GraphQL Specification.:integer- Represents a signed 32‐bit numeric non‐fractional value, greater than or equal to -2^31 and less than 2^31. Note that Absinthe uses the full word:integerto identify this type, but itsname(used by variables, for instance), is"Int". See the GraphQL Specification.:string- Represents textual data, represented as UTF‐8 character sequences. The String type is most often used by GraphQL to represent free‐form human‐readable text. See the GraphQL Specification.Examples
Supporting a time format in ISOz format, using Timex:
scalar :time do
description "Time (in ISOz format)"
parse &Timex.DateFormat.parse(&1, "{ISOz}")
serialize &Timex.DateFormat.format!(&1, "{ISOz}")
end
Link to this section Summary
Functions
Callback implementation for c:Absinthe.Introspection.TypeKind.kind/0.
Link to this section Types
Specs
t() :: %Absinthe.Type.Scalar{
__private__: Keyword.t(),
__reference__: Absinthe.Type.Reference.t(),
definition: module(),
description: binary(),
identifier: atom(),
name: binary(),
open_ended: term(),
parse: term(),
serialize: term()
}
A defined scalar type.
Note new scalars should be defined using Absinthe.Schema.Notation.scalar.
:name- The name of scalar. Should be a TitleCasedbinary. Set Automatically byAbsinthe.Schema.Notation.scalar.:description- A nice description for introspection.:serialize- A function used to convert a value to a form suitable for JSON serialization:parse- A function used to convert the raw, incoming form of a scalar to the canonical internal format.
The :__private__ and :__reference__ keys are for internal use.
Specs
value_t() :: any()
The internal, canonical representation of a scalar value
Link to this section Functions
Callback implementation for c:Absinthe.Introspection.TypeKind.kind/0.