question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CoerceFloat throwing error instead of parsing string to float from json

See original GitHub issue

Hi i notice that recently i started getting this error TypeError: Float cannot represent non numeric value: “234234234” at GraphQLScalarType.coerceFloat [as parseValue] i have another api that works fine when i started looking at the problem i realize that graphql was a different version where in version 14.1.1 coerceFloat is

function`` coerceFloat(value) {
  if (!(0, _isFinite.default)(value)) {
    throw new TypeError("Float cannot represent non numeric value: ".concat((0, _inspect.default)(value)));
  }

  return value;
}

in version 0.13.2 coerceFloat is

function` coerceFloat(value) {
  if (value === '') {
    throw new TypeError('Float cannot represent non numeric value: (empty string)');
  }
  var num = Number(value);
  if (num === num) {
    return num;
  }
  throw new TypeError('Float cannot represent non numeric value: ' + String(value));
}

when i copy paste second one in first one in scalar.js it just works fine

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
BePasquetcommented, Mar 15, 2019

@ivanGoncharov Thanks for building things like this for us

1reaction
IvanGoncharovcommented, Mar 15, 2019

sorry my ignorance but input type number return strings so all inputs on fe web apps will need to be parsed?

@BePasquet Yes, moreover it’s always a good idea to validate on fe. GraphQL validation is intended to assist with debugging during development that’s why error messages are not user-friendly and don’t support for internationalization.

Read more comments on GitHub >

github_iconTop Results From Across the Web

It's not possible to convert a string from JsonObject to float in ...
I am using the 'Socket.IO for Unity' plugin and sending data to the server using JSONObject, but ...
Read more >
The Basics - Simdjson
The simdjson library relies on an approach to parsing JSON that we call "On Demand". A document is not a fully-parsed JSON value;...
Read more >
How to parse a JSON with Python? - ReqBin
The Python JSON Parser library does not throw duplicate key exceptions. It ignores duplicate key-value pairs and takes the last key-value pair.
Read more >
Bloblang Methods - Benthos
Split a string value into an array of strings by splitting it on a string ... of an integer or contains decimal values...
Read more >
SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
The JavaScript exceptions thrown by JSON.parse() occur when string failed to be ... Instead write just 1 without a zero and use at...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found