Skip to content

Commit 24e1a35

Browse files
no1semanTotktonada
authored andcommitted
Rename defaultValues to variablesDefaultValues in execute.getFieldEntry()
1 parent 0caab75 commit 24e1a35

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

graphql/execute.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,12 @@ local function getFieldEntry(objectType, object, fields, context)
247247
argumentMap[argument.name.value] = argument
248248
end
249249

250-
local defaultValues = {}
250+
local variablesDefaultValues = {}
251251
if context.operation.variableDefinitions ~= nil then
252252
for _, value in ipairs(context.operation.variableDefinitions) do
253253
if value.defaultValue ~= nil then
254254
local variableType = query_util.typeFromAST(value.type, context.schema)
255-
defaultValues[value.variable.name.value] = util.coerceValue(value.defaultValue, variableType)
255+
variablesDefaultValues[value.variable.name.value] = util.coerceValue(value.defaultValue, variableType)
256256
end
257257
end
258258
end
@@ -268,7 +268,7 @@ local function getFieldEntry(objectType, object, fields, context)
268268

269269
return util.coerceValue(supplied, argument, context.variables, {
270270
strict_non_null = true,
271-
defaultValues = defaultValues,
271+
defaultValues = variablesDefaultValues,
272272
})
273273
end)
274274

@@ -316,7 +316,7 @@ local function getFieldEntry(objectType, object, fields, context)
316316
if argument.kind then argument = argument.kind end
317317
return util.coerceValue(supplied, argument, context.variables, {
318318
strict_non_null = true,
319-
defaultValues = defaultValues,
319+
defaultValues = variablesDefaultValues,
320320
})
321321
end)
322322
end)

test/integration/graphql_test.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,17 @@ function g.test_custom_directives()
14251425
data, errors = check_request(query, query_schema, nil, directives)
14261426
t.assert_equals(data, { test_G = '{"num":5,"str":"news"}' })
14271427
t.assert_equals(errors, nil)
1428+
1429+
-- check custom directives with variables
1430+
local variables = {num = 33}
1431+
1432+
query = [[query TEST($num: Int, $str: String = "variable") {
1433+
test_G: test(arg: { num: 2, str: "s" })@override_v2(arg: { num: $num, str: $str })
1434+
}]]
1435+
1436+
data, errors = check_request(query, query_schema, nil, directives, {variables = variables})
1437+
t.assert_equals(data, { test_G = '{"num":33,"str":"variable"}' })
1438+
t.assert_equals(errors, nil)
14281439
end
14291440

14301441
function g.test_specifiedByURL_scalar_field()

0 commit comments

Comments
 (0)