2121 "GraphQLString" ,
2222 "GraphQLBoolean" ,
2323 "GraphQLID" ,
24+ "GRAPHQL_MAX_INT" ,
25+ "GRAPHQL_MIN_INT" ,
2426]
2527
26-
27- # As per the GraphQL Spec, Integers are only treated as valid when a valid
28- # 32-bit signed integer, providing the broadest support across platforms.
29- #
30- # n.b. JavaScript's integers are safe between -(2^53 - 1) and 2^53 - 1 because
31- # they are internally represented as IEEE 754 doubles,
28+ # As per the GraphQL Spec, Integers are only treated as valid
29+ # when they can be represented as a 32-bit signed integer,
30+ # providing the broadest support across platforms.
31+ # n.b. JavaScript's numbers are safe between -(2^53 - 1) and 2^53 - 1
32+ # because they are internally represented as IEEE 754 doubles,
3233# while Python's integers may be arbitrarily large.
33- MAX_INT = 2_147_483_647
34- MIN_INT = - 2_147_483_648
34+
35+ GRAPHQL_MAX_INT = 2_147_483_647
36+ """Maximum possible Int value as per GraphQL Spec (32-bit signed integer)"""
37+
38+ GRAPHQL_MIN_INT = - 2_147_483_648
39+ """Minimum possible Int value as per GraphQL Spec (32-bit signed integer)"""
3540
3641
3742def serialize_int (output_value : Any ) -> int :
@@ -53,7 +58,7 @@ def serialize_int(output_value: Any) -> int:
5358 raise GraphQLError (
5459 "Int cannot represent non-integer value: " + inspect (output_value )
5560 )
56- if not MIN_INT <= num <= MAX_INT :
61+ if not GRAPHQL_MIN_INT <= num <= GRAPHQL_MAX_INT :
5762 raise GraphQLError (
5863 "Int cannot represent non 32-bit signed integer value: "
5964 + inspect (output_value )
@@ -72,7 +77,7 @@ def coerce_int(input_value: Any) -> int:
7277 raise GraphQLError (
7378 "Int cannot represent non-integer value: " + inspect (input_value )
7479 )
75- if not MIN_INT <= input_value <= MAX_INT :
80+ if not GRAPHQL_MIN_INT <= input_value <= GRAPHQL_MAX_INT :
7681 raise GraphQLError (
7782 "Int cannot represent non 32-bit signed integer value: "
7883 + inspect (input_value )
@@ -88,7 +93,7 @@ def parse_int_literal(value_node: ValueNode, _variables: Any = None) -> int:
8893 value_node ,
8994 )
9095 num = int (value_node .value )
91- if not MIN_INT <= num <= MAX_INT :
96+ if not GRAPHQL_MIN_INT <= num <= GRAPHQL_MAX_INT :
9297 raise GraphQLError (
9398 "Int cannot represent non 32-bit signed integer value: "
9499 + print_ast (value_node ),
0 commit comments