Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Commit 079a916

Browse files
committed
Fixup after enabling recursive variables validation
1 parent 7c3b14c commit 079a916

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

graphql/convert_schema/union.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ local function create_union_types(avro_schema, opts)
9898
if type == 'null' then
9999
is_nullable = true
100100
else
101-
local variant_type = convert(type, {context = context})
102101
local box_field_name = type.name or avro_helpers.avro_type(type)
102+
table.insert(context.path, box_field_name)
103+
local variant_type = convert(type, {context = context})
104+
table.remove(context.path, #context.path)
103105
union_types[#union_types + 1] = box_type(variant_type,
104106
box_field_name, {
105107
gen_argument = gen_argument,

graphql/core/rules.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,9 @@ function rules.variableUsageAllowed(node, context)
549549
end
550550

551551
if not isTypeSubTypeOf(variableType, argumentType) then
552-
error('Variable type mismatch')
552+
error(('Variable "%s" type mismatch: expected "%s", got "%s"')
553+
:format(variableName, tostring(variableType.name),
554+
tostring(argumentType.name)))
553555
end
554556
elseif argument.value.kind == 'inputObject' then
555557
for _, child in ipairs(argument.value.values) do

test/testdata/common_testdata.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1566,9 +1566,11 @@ function common_testdata.run_queries(gql_wrapper)
15661566
}
15671567
}
15681568
]]
1569-
local ok, err = pcall(gql_wrapper.compile, gql_wrapper, query_20)
1569+
local ok, _ = pcall(gql_wrapper.compile, gql_wrapper, query_20)
15701570
test:is(ok, true, 'correct variable usage as InputUnion')
15711571

1572+
-- XXX: add offset (non-null argument) case: make proper error is the case
1573+
15721574
-- }}}
15731575

15741576
assert(test:check(), 'check plan')

test/testdata/compound_index_testdata.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ function compound_index_testdata.run_queries(gql_wrapper)
13181318
-- (top-level collection, full primary key)
13191319

13201320
local query_6 = [[
1321-
query users($limit: Int, $user_str: String, $user_num: Long) {
1321+
query users($limit: Int, $user_str: String!, $user_num: Long!) {
13221322
user_collection(limit: $limit, offset: {user_str: $user_str,
13231323
user_num: $user_num}) {
13241324
user_str

0 commit comments

Comments
 (0)