Skip to content

Commit

Permalink
Respect n at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Dec 15, 2019
1 parent 0bca6e6 commit 799ce19
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/resolvers/BigInt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import { GraphQLScalarType } from 'graphql/type/definition';
import { Kind } from 'graphql/language/kinds';

export const coerceBigInt = (value: any) => {
if (typeof value === 'string') {
value = value.toString().replace('n', '');
}
if (typeof BigInt === 'undefined') {
const numberStr = value.toString().replace('n', '');
const number = Number(numberStr);
const number = Number(value);
if (!Number.isInteger(number)) {
throw new Error(`${value} is not an integer!`);
}
Expand Down

0 comments on commit 799ce19

Please sign in to comment.