Skip to content

Commit

Permalink
Improve test coverage
Browse files Browse the repository at this point in the history
Last entries line in multiline table considered as non-covered by luacov
if it has no trailing comma. See more about the issue in luacov repo:
lunarmodules/luacov#52

Based on PR #18 by @no1seman
  • Loading branch information
DifferentialOrange authored and Totktonada committed Nov 18, 2021
1 parent cd375d0 commit b7eaca4
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 95 deletions.
6 changes: 4 additions & 2 deletions graphql/execute.lua
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ local function getFieldEntry(objectType, object, fields, context)
if argument and argument.value then
positions[pos] = {
name=argument.name.value,
value=arguments[argument.name.value]
value=arguments[argument.name.value],
}
pos = pos + 1
end
Expand Down Expand Up @@ -345,4 +345,6 @@ local function execute(schema, tree, rootValue, variables, operationName)
end


return {execute=execute}
return {
execute = execute,
}
114 changes: 57 additions & 57 deletions graphql/introspection.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,31 @@ __Schema = types.object({
kind = types.nonNull(types.list(types.nonNull(__Type))),
resolve = function(schema)
return util.values(schema:getTypeMap())
end
end,
},

queryType = {
description = 'The type that query operations will be rooted at.',
kind = __Type.nonNull,
resolve = function(schema)
return schema:getQueryType()
end
end,
},

mutationType = {
description = 'If this server supports mutation, the type that mutation operations will be rooted at.',
kind = __Type,
resolve = function(schema)
return schema:getMutationType()
end
end,
},

subscriptionType = {
description = 'If this server supports mutation, the type that mutation operations will be rooted at.',
kind = __Type,
resolve = function(_)
return nil
end
end,
},


Expand All @@ -72,10 +72,10 @@ __Schema = types.object({
kind = types.nonNull(types.list(types.nonNull(__Directive))),
resolve = function(schema)
return schema.directives
end
}
end,
},
}
end
end,
})

__Directive = types.object({
Expand Down Expand Up @@ -111,15 +111,15 @@ __Directive = types.object({
if directive.onInlineFragment then table.insert(res, 'INLINE_FRAGMENT') end

return res
end
end,
},

args = {
kind = types.nonNull(types.list(types.nonNull(__InputValue))),
resolve = resolveArgs
}
resolve = resolveArgs,
},
}
end
end,
})

__DirectiveLocation = types.enum({
Expand All @@ -133,34 +133,34 @@ __DirectiveLocation = types.enum({
values = {
QUERY = {
value = 'QUERY',
description = 'Location adjacent to a query operation.'
description = 'Location adjacent to a query operation.',
},

MUTATION = {
value = 'MUTATION',
description = 'Location adjacent to a mutation operation.'
description = 'Location adjacent to a mutation operation.',
},

FIELD = {
value = 'FIELD',
description = 'Location adjacent to a field.'
description = 'Location adjacent to a field.',
},

FRAGMENT_DEFINITION = {
value = 'FRAGMENT_DEFINITION',
description = 'Location adjacent to a fragment definition.'
description = 'Location adjacent to a fragment definition.',
},

FRAGMENT_SPREAD = {
value = 'FRAGMENT_SPREAD',
description = 'Location adjacent to a fragment spread.'
description = 'Location adjacent to a fragment spread.',
},

INLINE_FRAGMENT = {
value = 'INLINE_FRAGMENT',
description = 'Location adjacent to an inline fragment.'
}
}
description = 'Location adjacent to an inline fragment.',
},
},
})

__Type = types.object({
Expand Down Expand Up @@ -205,16 +205,16 @@ __Type = types.object({
end

error('Unknown type ' .. kind)
end
end,
},

fields = {
kind = types.list(types.nonNull(__Field)),
arguments = {
includeDeprecated = {
kind = types.boolean,
defaultValue = false
}
defaultValue = false,
},
},
resolve = function(kind, arguments)
if kind.__type == 'Object' or kind.__type == 'Interface' then
Expand All @@ -233,7 +233,7 @@ __Type = types.object({
if kind.__type == 'Object' then
return kind.interfaces or {}
end
end
end,
},

possibleTypes = {
Expand All @@ -242,21 +242,21 @@ __Type = types.object({
if kind.__type == 'Interface' or kind.__type == 'Union' then
return context.schema:getPossibleTypes(kind)
end
end
end,
},

enumValues = {
kind = types.list(types.nonNull(__EnumValue)),
arguments = {
includeDeprecated = { kind = types.boolean, defaultValue = false }
includeDeprecated = { kind = types.boolean, defaultValue = false },
},
resolve = function(kind, arguments)
if kind.__type == 'Enum' then
return util.filter(util.values(kind.values), function(value)
return arguments.includeDeprecated or not value.deprecationReason
end)
end
end
end,
},

inputFields = {
Expand All @@ -265,14 +265,14 @@ __Type = types.object({
if kind.__type == 'InputObject' then
return util.values(kind.fields)
end
end
end,
},

ofType = {
kind = __Type
}
kind = __Type,
},
}
end
end,
})

__Field = types.object({
Expand All @@ -290,26 +290,26 @@ __Field = types.object({

args = {
kind = types.nonNull(types.list(types.nonNull(__InputValue))),
resolve = resolveArgs
resolve = resolveArgs,
},

type = {
kind = __Type.nonNull,
resolve = function(field)
return field.kind
end
end,
},

isDeprecated = {
kind = types.boolean.nonNull,
resolve = function(field)
return field.deprecationReason ~= nil
end
end,
},

deprecationReason = types.string
deprecationReason = types.string,
}
end
end,
})

__InputValue = types.object({
Expand All @@ -330,18 +330,18 @@ __InputValue = types.object({
kind = types.nonNull(__Type),
resolve = function(field)
return field.kind
end
end,
},

defaultValue = {
kind = types.string,
description = 'A GraphQL-formatted string representing the default value for this input value.',
resolve = function(inputVal)
return inputVal.defaultValue and tostring(inputVal.defaultValue) -- TODO improve serialization a lot
end
}
end,
},
}
end
end,
})

__EnumValue = types.object({
Expand All @@ -361,9 +361,9 @@ __EnumValue = types.object({
kind = types.boolean.nonNull,
resolve = function(enumValue) return enumValue.deprecationReason ~= nil end
},
deprecationReason = types.string
deprecationReason = types.string,
}
end
end,
})

__TypeKind = types.enum({
Expand All @@ -372,44 +372,44 @@ __TypeKind = types.enum({
values = {
SCALAR = {
value = 'SCALAR',
description = 'Indicates this type is a scalar.'
description = 'Indicates this type is a scalar.',
},

OBJECT = {
value = 'OBJECT',
description = 'Indicates this type is an object. `fields` and `interfaces` are valid fields.'
description = 'Indicates this type is an object. `fields` and `interfaces` are valid fields.',
},

INTERFACE = {
value = 'INTERFACE',
description = 'Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.'
description = 'Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.',
},

UNION = {
value = 'UNION',
description = 'Indicates this type is a union. `possibleTypes` is a valid field.'
description = 'Indicates this type is a union. `possibleTypes` is a valid field.',
},

ENUM = {
value = 'ENUM',
description = 'Indicates this type is an enum. `enumValues` is a valid field.'
description = 'Indicates this type is an enum. `enumValues` is a valid field.',
},

INPUT_OBJECT = {
value = 'INPUT_OBJECT',
description = 'Indicates this type is an input object. `inputFields` is a valid field.'
description = 'Indicates this type is an input object. `inputFields` is a valid field.',
},

LIST = {
value = 'LIST',
description = 'Indicates this type is a list. `ofType` is a valid field.'
description = 'Indicates this type is a list. `ofType` is a valid field.',
},

NON_NULL = {
value = 'NON_NULL',
description = 'Indicates this type is a non-null. `ofType` is a valid field.'
}
}
description = 'Indicates this type is a non-null. `ofType` is a valid field.',
},
},
})

local Schema = {
Expand All @@ -419,19 +419,19 @@ local Schema = {
arguments = {},
resolve = function(_, _, info)
return info.schema
end
end,
}

local Type = {
name = '__type',
kind = __Type,
description = 'Request the type information of a single type.',
arguments = {
name = types.string.nonNull
name = types.string.nonNull,
},
resolve = function(_, arguments, info)
return info.schema:getType(arguments.name)
end
end,
}

local TypeName = {
Expand All @@ -441,7 +441,7 @@ local TypeName = {
arguments = {},
resolve = function(_, _, info)
return info.parentType.name
end
end,
}

return {
Expand All @@ -458,6 +458,6 @@ return {
fieldMap = {
__schema = Schema,
__type = Type,
__typename = TypeName
}
__typename = TypeName,
},
}
2 changes: 1 addition & 1 deletion graphql/rules.lua
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function rules.unambiguousSelections(node, context)
local fieldEntry = {
parent = parentType,
field = selection,
definition = definition
definition = definition,
}

validateField(key, fieldEntry)
Expand Down
2 changes: 1 addition & 1 deletion graphql/schema.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function schema.create(config, name)

self.directives = self.directives or {
types.include,
types.skip
types.skip,
}

self.typeMap = {}
Expand Down
Loading

0 comments on commit b7eaca4

Please sign in to comment.