Closed
Description
The main problem that our graphql coerseValue doesn't consider hierarchical structure of input object.
See also tarantool/cartridge@fb4b3a3
diff --git a/test/integration/graphql_test.lua b/test/integration/graphql_test.lua
index a4d11e8..0bf9704 100644
--- a/test/integration/graphql_test.lua
+++ b/test/integration/graphql_test.lua
@@ -558,11 +558,25 @@ function g.test_custom_type_scalar_variables()
if args.field == nil then
return nil
end
- assert(type(args.field) == 'table', "Field is not a table! ")
- assert(args.field.test ~= nil, "No field 'test' in object!")
+ t.assert_type(args.field, 'table', "Field is not a table! ")
+ t.assert_not_equals(args.field.test, nil, "No field 'test' in object!")
return args.field
end
},
+ ['test_json_type_list'] = {
+ arguments = {
+ array = types.list(json_type),
+ },
+ kind = types.list(json_type),
+ resolve = function(_, args)
+ if args.array == nil then
+ return nil
+ end
+ t.assert_type(args.array[1], 'table', "Array element is not a table! ")
+ t.assert_not_equals(args.array[1].test, nil, "No field 'test' in array element!")
+ return args.array
+ end
+ },
['test_custom_type_scalar_list'] = {
kind = types.string,
arguments = {
@@ -623,6 +637,16 @@ function g.test_custom_type_scalar_variables()
variables = {},
}), {test_json_type = 'null'})
+ t.assert_equals(check_request([[
+ query($array: [Json]) {
+ test_json_type_list(
+ array: $array
+ )
+ }
+ ]], query_schema, {
+ variables = {array = {json.encode({test = 123})}},
+ }), {test_json_type_list = {'{"test":123}'}})
+
t.assert_equals(check_request([[
query($field: CustomString!) {
test_custom_type_scalar(