Skip to content

Commit

Permalink
Improve test coverage
Browse files Browse the repository at this point in the history
Last 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 committed Nov 15, 2021
1 parent b68ef16 commit fedcbf7
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 66 deletions.
90 changes: 45 additions & 45 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,7 +72,7 @@ __Schema = types.object({
kind = types.nonNull(types.list(types.nonNull(__Directive))),
resolve = function(schema)
return schema.directives
end
end,
}
}
end
Expand Down Expand Up @@ -111,12 +111,12 @@ __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
Expand All @@ -133,33 +133,33 @@ __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.',
},
}
})

Expand Down Expand Up @@ -205,15 +205,15 @@ __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)
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,7 +242,7 @@ __Type = types.object({
if kind.__type == 'Interface' or kind.__type == 'Union' then
return context.schema:getPossibleTypes(kind)
end
end
end,
},

enumValues = {
Expand All @@ -256,7 +256,7 @@ __Type = types.object({
return arguments.includeDeprecated or not value.deprecationReason
end)
end
end
end,
},

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

ofType = {
kind = __Type
}
kind = __Type,
},
}
end
})
Expand All @@ -290,24 +290,24 @@ __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
})
Expand All @@ -330,16 +330,16 @@ __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
})
Expand All @@ -361,7 +361,7 @@ __EnumValue = types.object({
kind = types.boolean.nonNull,
resolve = function(enumValue) return enumValue.deprecationReason ~= nil end
},
deprecationReason = types.string
deprecationReason = types.string,
}
end
})
Expand All @@ -372,43 +372,43 @@ __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.',
},
}
})

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
Loading

0 comments on commit fedcbf7

Please sign in to comment.