Bird
0
0

What will be the result type of this GraphQL query field if declared as Float?

medium📝 query result Q5 of 15
GraphQL - Schema Definition Language (SDL)
What will be the result type of this GraphQL query field if declared as Float?
{ rating: 4 }
Choose the correct explanation.
AThe value 4 will be converted to string.
BThe query will fail because 4 is not a float.
CThe value 4 is returned as an integer, but Float type accepts it.
DThe value 4 will be returned as Boolean true.
Step-by-Step Solution
Solution:
  1. Step 1: Understand Float scalar type behavior

    Float accepts decimal numbers but also whole numbers as valid floats.
  2. Step 2: Analyze the value 4 in context

    4 is an integer but can be represented as 4.0 in Float type without error.
  3. Final Answer:

    The value 4 is returned as an integer, but Float type accepts it. -> Option C
  4. Quick Check:

    Float accepts whole numbers = C [OK]
Quick Trick: Float can hold whole numbers too [OK]
Common Mistakes:
  • Expecting error for integer in Float
  • Assuming conversion to string
  • Confusing Boolean with Float

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes