Skip to content

Commit

Permalink
Fix BigInt handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Oct 10, 2023
1 parent 5b66cd5 commit 0d73e69
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/tender-spoons-burn.md
@@ -0,0 +1,5 @@
---
'graphql-scalars': patch
---

Fix BigInt handling
4 changes: 2 additions & 2 deletions src/scalars/BigInt.ts
Expand Up @@ -80,7 +80,7 @@ export const GraphQLBigIntConfig: GraphQLScalarTypeConfig<
if (inputValue.toString() !== bigint.toString()) {
throw createGraphQLError(`BigInt cannot represent value: ${inputValue}`);
}
if (!isSafeInteger(bigint) && !isBigIntSerializable()) {
if (isSafeInteger(bigint) && !isBigIntSerializable()) {
return Number(bigint.toString());
}
return bigint;
Expand All @@ -96,7 +96,7 @@ export const GraphQLBigIntConfig: GraphQLScalarTypeConfig<
if (strOrBooleanValue.toString() !== bigint.toString()) {
throw createGraphQLError(`BigInt cannot represent value: ${strOrBooleanValue}`);
}
if (!isSafeInteger(bigint) && !isBigIntSerializable()) {
if (isSafeInteger(bigint) && !isBigIntSerializable()) {
return Number(bigint.toString());
}
return bigint;
Expand Down

0 comments on commit 0d73e69

Please sign in to comment.