@@ -96,7 +96,7 @@ function g.test_variables()
9696 local function callback (_ , args )
9797 local result = ' '
9898 for _ , tuple in ipairs (getmetatable (args ).__index ) do
99- result = result .. tuple .value
99+ result = result .. tostring ( tuple .value )
100100 end
101101 return result
102102 end
@@ -184,10 +184,10 @@ function g.test_variables()
184184 )
185185
186186 t .assert_error_msg_equals (
187- ' Could not coerce value "18446744073709551614 " to type "Long"' ,
187+ ' Could not coerce value "18446744073709551617 " to type "Long"' ,
188188 function ()
189189 check_request ([[
190- query { test(arg: "", arg4: 18446744073709551614 ) }
190+ query { test(arg: "", arg4: 18446744073709551617 ) }
191191 ]] , query_schema )
192192 end
193193 )
@@ -2147,3 +2147,37 @@ function g.test_non_finite_float()
21472147 query_schema , nil , nil , {variables = variables })
21482148 end
21492149end
2150+
2151+ function g .test_huge_cdata_number ()
2152+ local query = [[
2153+ query ($x: Long!) { test(arg: $x) }
2154+ ]]
2155+
2156+ local function callback (_ , args )
2157+ return args [1 ].value
2158+ end
2159+
2160+ local query_schema = {
2161+ [' test' ] = {
2162+ kind = types .long .nonNull ,
2163+ arguments = {
2164+ arg = types .long .nonNull ,
2165+ },
2166+ resolve = callback ,
2167+ }
2168+ }
2169+
2170+ local test_values = {
2171+ {4503599627370495 ULL, " {\" test\" :4503599627370495}" },
2172+ {9223372036854775807 ULL, " {\" test\" :9223372036854775807}" },
2173+ {- 1 LL, " {\" test\" :-1}" },
2174+ {- 1 ULL, " {\" test\" :18446744073709551615}" }}
2175+
2176+ for _ , v in ipairs (test_values ) do
2177+ local variables = {x = v [1 ]}
2178+ local res = check_request (query , query_schema , nil , nil , {variables = variables })
2179+ t .assert_type (res , ' table' )
2180+ t .assert_equals (res .test , v [1 ])
2181+ t .assert_equals (json .encode (res ), v [2 ])
2182+ end
2183+ end
0 commit comments