@@ -5,6 +5,10 @@ local introspection = require(path .. '.introspection')
5
5
local query_util = require (path .. ' .query_util' )
6
6
local validate_variables = require (path .. ' .validate_variables' )
7
7
8
+ local function error (...)
9
+ return _G .error (... , 0 )
10
+ end
11
+
8
12
local function getFieldResponseKey (field )
9
13
return field .alias and field .alias .name .value or field .name .value
10
14
end
@@ -236,16 +240,26 @@ local function getFieldEntry(objectType, object, fields, context)
236
240
argumentMap [argument .name .value ] = argument
237
241
end
238
242
243
+ local defaultValues = {}
244
+ if context .operation .variableDefinitions ~= nil then
245
+ for _ , value in ipairs (context .operation .variableDefinitions ) do
246
+ if value .defaultValue ~= nil then
247
+ local variableType = query_util .typeFromAST (value .type , context .schema )
248
+ defaultValues [value .variable .name .value ] = util .coerceValue (value .defaultValue , variableType )
249
+ end
250
+ end
251
+ end
252
+
239
253
local arguments = util .map (fieldType .arguments or {}, function (argument , name )
240
254
local supplied = argumentMap [name ] and argumentMap [name ].value
241
255
242
256
supplied = util .coerceValue (supplied , argument , context .variables ,
243
257
{strict_non_null = true })
244
- if supplied ~= nil then
258
+ if type ( supplied ) ~= ' nil' then
245
259
return supplied
246
260
end
247
261
248
- return argument . defaultValue
262
+ return defaultValues [ name ]
249
263
end )
250
264
251
265
--[[
0 commit comments