GraphQL specification defines 5 built-in scalar types - String
, Int
, Float
, Boolean
and ID
(a string with a unique identifier). These types are JSON serializable and available in every programming language.
Be careful with the built-in scalar Int
type:
signed 32-bit integer
.-2^31
or greater than or equal to 2^31
, a field error should be raised.-2'147'483'648
/ 2'147'483'647
.These numbers in real life:
If you return from the backend or pass via client an argument whose value is not within the 32-bit Int
interval - you'll get an error: Int cannot represent non-32-bit signed integer value.
However, when a scalar type is not representable in JSON by default (e.g. Date
) the backend has to figure out a data format that can be serializable and transmittable via JSON. The backend also needs to deserialize the field received from a client.
In such cases, GraphQL allows you to create your own custom scalar types.