Represents a primitive value in GraphQL. GraphQL responses take the form of a hierarchical tree; the leaves on these trees are GraphQL scalars.
scalar
In an Absinthe schema, defining a custom scalar type by providing functions to parse input and serialize results:
| scalar :datetime, name: "DateTime" do |
| serialize &DateTime.to_iso8601/1 |
| parse &parse_datetime/1 |
| end |
A number of built-in scalar types are part of the specification and are predefined for you by Absinthe.
The Boolean scalar type represents true or false.
:boolean
The Float scalar type represents signed double-precision fractional values as specified by IEEE 754. Response formats that support an appropriate double-precision number type should use that type to represent this scalar.
:float
The ID scalar type represents a unique identifier, often used to refetch an object or as the 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. While it is often numeric, it should always serialize as a String.
:id
The Int scalar type represents a signed 32-bit numeric non-fractional value. Response formats that support a 32-bit integer or a number type should use that type to represent this scalar.
:integer
Represents textual data as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
:string
Absinthe ships with a number of custom scalars predefined for convenience. They are found in Absinthe.Type.Custom and include:
To use these scalar types, add the following to your Absinthe schema:
| import_types Absinthe.Type.Custom |
3.145.39.60