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

Commit 36820b8

Browse files
committed
Add missing numeric avro types and bool
Closes #31
1 parent b3dc9a9 commit 36820b8

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

graphql/core/types.lua

+12-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ end
205205

206206
types.int = types.scalar({
207207
name = 'Int',
208-
description = "The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1. ",
208+
description = "The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1. ",
209209
serialize = coerceInt,
210210
parseValue = coerceInt,
211211
parseLiteral = function(node)
@@ -226,6 +226,17 @@ types.float = types.scalar({
226226
end
227227
})
228228

229+
types.double = types.scalar({
230+
name = 'Double',
231+
serialize = tonumber,
232+
parseValue = tonumber,
233+
parseLiteral = function(node)
234+
if node.kind == 'double' or node.kind == 'int' then
235+
return tonumber(node.value)
236+
end
237+
end
238+
})
239+
229240
types.string = types.scalar({
230241
name = 'String',
231242
description = "The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.",

graphql/tarantool_graphql.lua

+24
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ local function avro_type(avro_schema)
7373
return 'long'
7474
elseif avro_schema == 'long*' then
7575
return 'long*'
76+
elseif avro_schema == 'double' then
77+
return 'double'
78+
elseif avro_schema == 'double*' then
79+
return 'double*'
80+
elseif avro_schema == 'float' then
81+
return 'float'
82+
elseif avro_schema == 'float*' then
83+
return 'float*'
84+
elseif avro_schema == 'boolean' then
85+
return 'boolean'
86+
elseif avro_schema == 'boolean*' then
87+
return 'boolean*'
7688
elseif avro_schema == 'string' then
7789
return 'string'
7890
elseif avro_schema == 'string*' then
@@ -136,6 +148,18 @@ local function convert_scalar_type(avro_schema, opts)
136148
return types_long.nonNull
137149
elseif avro_t == 'long*' then
138150
return types_long
151+
elseif avro_t == 'float' then
152+
return types.float.nonNull
153+
elseif avro_t == 'float*' then
154+
return types.float
155+
elseif avro_t == 'double' then
156+
return types.double.nonNull
157+
elseif avro_t == 'double*' then
158+
return types.double
159+
elseif avro_t == 'boolean' then
160+
return types.boolean.nonNull
161+
elseif avro_t == 'boolean*' then
162+
return types.boolean
139163
elseif avro_t == 'string' then
140164
return types.string.nonNull
141165
elseif avro_t == 'string*' then

0 commit comments

Comments
 (0)