Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

GraphQL · Const

GraphQLFloat

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.

How it works

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.

Syntax

Float

Returns

A finite signed double-precision IEEE 754 value.

Key points

  • Float represents finite signed double-precision numbers under IEEE 754.
  • Float arguments accept both integer literals and floating-point literals.
  • An integer input is converted to its floating-point equivalent.
  • Resolvers should normally provide double-precision floating-point values for Float fields.
  • A service can convert another numeric internal value when the conversion is reasonable and lossless.
  • The transport representation should use its available double-precision numeric type.

Common mistakes

  • NaN and Infinity are not valid Float results and must produce a field error.
  • Numeric strings are not accepted as Float inputs, even when their contents look like numbers.

Example: Query a Float field

query ProductPrice {
  product {
    price
  }
}

A field declared as Float can return a finite double-precision numeric value.

When to use it

Declare decimal-valued fields such as measurements, rates, or prices.

Schema design

Accept numeric filters or calculation inputs that may contain fractional values.

Query arguments

Expose finite double-precision values from application data.

Resolver results

Interview questions

QWhat does GraphQL Float represent?

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.

QWhich input values can a Float argument accept?

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.

QHow are resolver results serialized or coerced for Float?

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.

  • Int
  • String
  • Boolean
  • ID
  • Scalar types

Source: GraphQL Specification. Checked 2026-10-15.