Declare decimal-valued fields such as measurements, rates, or prices.
Schema design
GraphQL · Const
GraphQLFloat is GraphQL’s built-in Float scalar for finite signed double-precision IEEE 754 values. It accepts integer or floating-point inputs, while invalid or non-finite values cause errors.
GraphQLFloat is GraphQL's built-in Float scalar. It represents finite signed double-precision IEEE 754 values, accepts integer and floating-point inputs, and rejects strings or non-finite values when they cannot be represented correctly.
FloatA finite signed double-precision IEEE 754 value.
query ProductPrice {
product {
price
}
}A field declared as Float can return a finite double-precision numeric value.
Schema design
Query arguments
Resolver results
Float is a built-in scalar representing signed, finite, double-precision IEEE 754 values. A service should expose an appropriate double-precision number representation for it.
Follow-up: What happens when a resolver returns an integer? It may be coerced to Float when reasonable without losing information, such as returning 1.0 for 1.
Both integer and Float literal inputs are accepted for a Float argument. An integer is converted by adding an empty fractional part, so 1 becomes 1.0.
Follow-up: Are numeric strings equivalent? No. Strings with numeric content must be rejected as an incorrect input type.
A field returning Float expects a double-precision floating-point internal value. Non-floating-point values may be coerced when reasonable and lossless; otherwise execution must report a field error.
Follow-up: What special values are invalid? NaN and Infinity cannot be coerced to Float and must cause a field error.
IntStringBooleanIDScalar types