From 23864c1fe595ee0140dc86335d26bba097f85d63 Mon Sep 17 00:00:00 2001 From: overhead525 Date: Sat, 23 May 2020 19:38:39 -0400 Subject: [PATCH 1/2] export constants MAX_INT and MIN_INT --- src/type/scalars.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/type/scalars.js b/src/type/scalars.js index e425a17067..1bd1b27f73 100644 --- a/src/type/scalars.js +++ b/src/type/scalars.js @@ -18,8 +18,8 @@ import { type GraphQLNamedType, GraphQLScalarType } from './definition'; // // n.b. JavaScript's integers are safe between -(2^53 - 1) and 2^53 - 1 because // they are internally represented as IEEE 754 doubles. -const MAX_INT = 2147483647; -const MIN_INT = -2147483648; +export const MAX_INT = 2147483647; +export const MIN_INT = -2147483648; function serializeInt(outputValue: mixed): number { const coercedValue = serializeObject(outputValue); @@ -41,7 +41,7 @@ function serializeInt(outputValue: mixed): number { if (num > MAX_INT || num < MIN_INT) { throw new GraphQLError( 'Int cannot represent non 32-bit signed integer value: ' + - inspect(coercedValue), + inspect(coercedValue), ); } return num; @@ -266,7 +266,7 @@ export const GraphQLID = new GraphQLScalarType({ if (valueNode.kind !== Kind.STRING && valueNode.kind !== Kind.INT) { throw new GraphQLError( 'ID cannot represent a non-string and non-integer value: ' + - print(valueNode), + print(valueNode), valueNode, ); } @@ -282,6 +282,6 @@ export const specifiedScalarTypes = Object.freeze([ GraphQLID, ]); -export function isSpecifiedScalarType(type: GraphQLNamedType): boolean %checks { +export function isSpecifiedScalarType(type: GraphQLNamedType): boolean % checks { return specifiedScalarTypes.some(({ name }) => type.name === name); } From 92567d65dd7b2c230d3221883196000ff6a89142 Mon Sep 17 00:00:00 2001 From: overhead525 Date: Sun, 7 Jun 2020 19:43:51 -0400 Subject: [PATCH 2/2] fix types for flow --- src/type/scalars.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/type/scalars.d.ts b/src/type/scalars.d.ts index 71593d10c2..39f942bd18 100644 --- a/src/type/scalars.d.ts +++ b/src/type/scalars.d.ts @@ -6,6 +6,9 @@ export const GraphQLString: GraphQLScalarType; export const GraphQLBoolean: GraphQLScalarType; export const GraphQLID: GraphQLScalarType; +export declare const MAX_INT: number; +export declare const MIN_INT: number; + export const specifiedScalarTypes: ReadonlyArray; export function isSpecifiedScalarType(type: GraphQLNamedType): boolean;