We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There are several issues opened regarding BigInt, none of them actually fixes the issue.
If maintainers do not want to create a new type like GraphQLBigInt, at least could be added support for custom type cast.
Example:
const { GraphQLScalarType } = require('graphql'); const { INT } = require ('graphql/language/kinds'); const MAX_INT = Number.MAX_SAFE_INTEGER; const MIN_INT = Number.MIN_SAFE_INTEGER; const coerceBigint = value => { if (value === '') { throw new TypeError( 'Bigint cannot represent non 64-bit signed integer value: (empty string)', ); } const num = BigInt(value); if (num > MAX_INT || num < MIN_INT) { throw new TypeError( `Bigint cannot represent non 64-bit signed integer value: ${String( value, )}`, ); } return num; }; const GraphQLBigInt = new GraphQLScalarType({ name: 'BigInt', description: 'The `Bigint` scalar type 64 bit', serialize: coerceBigint, parseValue: coerceBigint, parseLiteral(ast) { if (ast.kind === INT) { const num = BigInt(ast.value); if (num <= MAX_INT && num >= MIN_INT) { return num; } } return null; }, }); exports.GraphQLBigInt = GraphQLBigInt;
gives me the error:
Error: Schema must contain uniquely named types but contains multiple types named "BigInt"
So, technically the only way is to convert to String, which will not work for many cases.
Can we just suppress the error above, which will allow actually to use the BigInt?
The text was updated successfully, but these errors were encountered:
Closing the issue, as the problem is in JSON.serialize, which is not support BigInt yet.
Sorry, something went wrong.
No branches or pull requests
There are several issues opened regarding BigInt, none of them actually fixes the issue.
If maintainers do not want to create a new type like GraphQLBigInt, at least could be added support for custom type cast.
Example:
gives me the error:
So, technically the only way is to convert to String, which will not work for many cases.
Can we just suppress the error above, which will allow actually to use the BigInt?
The text was updated successfully, but these errors were encountered: