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

Add missing numeric avro types and bool #106

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion graphql/core/types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ end

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

types.double = types.scalar({
name = 'Double',
serialize = tonumber,
parseValue = tonumber,
parseLiteral = function(node)
if node.kind == 'float' or node.kind == 'int' then
return tonumber(node.value)
end
end
})

types.string = types.scalar({
name = 'String',
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.",
Expand Down
24 changes: 24 additions & 0 deletions graphql/tarantool_graphql.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ local function avro_type(avro_schema)
return 'long'
elseif avro_schema == 'long*' then
return 'long*'
elseif avro_schema == 'double' then
return 'double'
elseif avro_schema == 'double*' then
return 'double*'
elseif avro_schema == 'float' then
return 'float'
elseif avro_schema == 'float*' then
return 'float*'
elseif avro_schema == 'boolean' then
return 'boolean'
elseif avro_schema == 'boolean*' then
return 'boolean*'
elseif avro_schema == 'string' then
return 'string'
elseif avro_schema == 'string*' then
Expand Down Expand Up @@ -136,6 +148,18 @@ local function convert_scalar_type(avro_schema, opts)
return types_long.nonNull
elseif avro_t == 'long*' then
return types_long
elseif avro_t == 'float' then
return types.float.nonNull
elseif avro_t == 'float*' then
return types.float
elseif avro_t == 'double' then
return types.double.nonNull
elseif avro_t == 'double*' then
return types.double
elseif avro_t == 'boolean' then
return types.boolean.nonNull
elseif avro_t == 'boolean*' then
return types.boolean
elseif avro_t == 'string' then
return types.string.nonNull
elseif avro_t == 'string*' then
Expand Down