Skip to content

Commit 6b15568

Browse files
Fix describing type with table in schema
Before this patch, describing argument type in schema with a table resulted in "No value provided" error on query execution. Based on PR #22 by @no1seman
1 parent 7d2e9c9 commit 6b15568

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

graphql/execute.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ local function getFieldEntry(objectType, object, fields, context)
260260

261261
local arguments = util.map(fieldType.arguments or {}, function(argument, name)
262262
local supplied = argumentMap[name] and argumentMap[name].value
263+
if argument.kind then argument = argument.kind end
263264
return util.coerceValue(supplied, argument, context.variables, {
264265
strict_non_null = true,
265266
defaultValues = defaultValues,

test/integration/graphql_test.lua

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,3 +1509,29 @@ function g.test_specifiedBy_directive()
15091509
t.assert_equals(data, { test_A = { url = "http://localhost", value = "1" } })
15101510
t.assert_equals(errors, nil)
15111511
end
1512+
1513+
function g.test_schema_input_arg_described_with_kind()
1514+
local function callback(_, args)
1515+
return args[1].value
1516+
end
1517+
1518+
local query_schema = {
1519+
['test'] = {
1520+
kind = types.string.nonNull,
1521+
arguments = {
1522+
arg = {
1523+
kind = types.string.nonNull,
1524+
},
1525+
},
1526+
resolve = callback,
1527+
}
1528+
}
1529+
1530+
local query = [[
1531+
{ test(arg: "A") }
1532+
]]
1533+
1534+
local _, errors = check_request(query, query_schema, {})
1535+
t.assert_equals(errors, nil)
1536+
end
1537+

0 commit comments

Comments
 (0)