Skip to content

Commit 37ac005

Browse files
committed
Specify custom types description URL
1 parent 0104640 commit 37ac005

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

graphql/introspection.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,11 @@ __Type = types.object({
346346
end,
347347
},
348348

349-
specifiedByUrl = {
349+
specifiedByURL = {
350350
kind = types.string,
351351
resolve = function(kind)
352352
if kind.__type == 'Scalar' then
353-
return kind.specifiedByUrl
353+
return kind.specifiedByURL
354354
end
355355
end,
356356
},

graphql/types.lua

+4-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function types.scalar(config)
9696
parseValue = config.parseValue,
9797
parseLiteral = config.parseLiteral,
9898
isValueOfTheType = config.isValueOfTheType,
99-
specifiedByUrl = config.specifiedByUrl,
99+
specifiedByURL = config.specifiedByURL,
100100
}
101101

102102
instance.nonNull = types.nonNull(instance)
@@ -309,6 +309,7 @@ types.long = types.scalar({
309309
name = 'Long',
310310
description = "The `Long` scalar type represents non-fractional signed whole numeric values. " ..
311311
"Long can represent values from -(2^52) to 2^52 - 1, inclusive.",
312+
specifiedByURL = 'https://github.com/tarantool/graphql/wiki/Long',
312313
serialize = coerceLong,
313314
parseLiteral = function(node)
314315
return coerceLong(node.value)
@@ -331,6 +332,8 @@ end
331332

332333
types.float = types.scalar({
333334
name = 'Float',
335+
description = "The `Float` scalar type represents signed double-"..
336+
"precision fractional values as specified by IEEE 754.",
334337
serialize = coerceFloat,
335338
parseLiteral = function(node)
336339
return coerceFloat(node.value)

test/integration/graphql_test.lua

+21-3
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ function g.test_custom_directives()
14271427
t.assert_equals(errors, nil)
14281428
end
14291429

1430-
function g.test_specifiedByUrl_scalar_field()
1430+
function g.test_specifiedByURL_scalar_field()
14311431
local function callback(_, _)
14321432
return nil
14331433
end
@@ -1445,7 +1445,7 @@ function g.test_specifiedByUrl_scalar_field()
14451445
isValueOfTheType = function(_)
14461446
return true
14471447
end,
1448-
specifiedByUrl = 'http://localhost',
1448+
specifiedByURL = 'http://localhost',
14491449
})
14501450

14511451
local query_schema = {
@@ -1461,7 +1461,7 @@ function g.test_specifiedByUrl_scalar_field()
14611461
local data, errors = check_request(introspection.query, query_schema)
14621462
local CustomInt_schema = util.find_by_name(data.__schema.types, 'CustomInt')
14631463
t.assert_type(CustomInt_schema, 'table', 'CustomInt schema found on introspection')
1464-
t.assert_equals(CustomInt_schema.specifiedByUrl, 'http://localhost')
1464+
t.assert_equals(CustomInt_schema.specifiedByURL, 'http://localhost')
14651465
t.assert_equals(errors, nil)
14661466
end
14671467

@@ -1697,3 +1697,21 @@ function g.test_arguments_default_values()
16971697
local nested_enum_arg_defaults = util.find_by_name(test_input_object.inputFields, 'nested_enum_arg_defaults')
16981698
t.assert_equals(nested_enum_arg_defaults.defaultValue, 'write')
16991699
end
1700+
1701+
function g.test_specifiedByURL_long_scalar()
1702+
local query_schema = {
1703+
['test'] = {
1704+
kind = types.string.nonNull,
1705+
arguments = {
1706+
arg = types.long,
1707+
},
1708+
resolve = '',
1709+
}
1710+
}
1711+
1712+
local data, errors = check_request(introspection.query, query_schema)
1713+
local long_type_schema = util.find_by_name(data.__schema.types, 'Long')
1714+
t.assert_type(long_type_schema, 'table', 'Long scalar type found on introspection')
1715+
t.assert_equals(long_type_schema.specifiedByURL, 'https://github.com/tarantool/graphql/wiki/Long')
1716+
t.assert_equals(errors, nil)
1717+
end

test/integration/introspection.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ return {
2424
kind
2525
name
2626
description
27-
specifiedByUrl
27+
specifiedByURL
2828
fields(includeDeprecated: true) {
2929
name
3030
description

0 commit comments

Comments
 (0)