Checks
Checks Configuration.
Sample Config
kind: Checks
name: service-name
spec:
steps:
operational:
fail_on: warning
linting:
fail_on: error
disable: false
schema_lint_rules:
- level: error
disable: true
name: FIELD_NAMES_CAMEL_CASE
- level: warning
name: REST_FIELD_NAMES
Spec
This section defines the format of Inigo's Checks
type configuration files. Fields marked as required
must be specified if the parent is defined.
Field | Type | Description |
---|---|---|
steps | CheckSteps | Steps configuration. |
CheckSteps
Field | Type | Description |
---|---|---|
operational | OperationalStep | Operational step configuration. |
linting | LintingStep | Linting step configuration. |
composition | CompositionStep |
OperationalStep
Field | Type | Description |
---|---|---|
fail_on | string default:warning | Failure level. You can specify the level of the message that will cause the step to fail. One of: - undefined - debug - info - warning - error |
time_range | string default:"30d" | Provide a time range to use for breaking changes detection. For example: 1h, 10d, 1m. 0 means that check against analytics is disabled, 30d - max. String represents the duration in the form "72h3m0.5s". |
LintingStep
Field | Type | Description |
---|---|---|
fail_on | string default:error | Failure level. You can specify the level of the message that will cause the step to fail. One of: - undefined - debug - info - warning - error |
disable | boolean | Enable or disable linter. |
schema_lint_rules | [LintSchemaRule] |
LintSchemaRule
Field | Type | Description |
---|---|---|
name | string required | |
level | string required default:undefined | One of: - undefined - debug - info - warning - error |
disable | boolean |
CompositionStep
Field | Type | Description |
---|---|---|
auto_publish | boolean default:true |
Schema Linting Fine Tuning
To fine tune some schema specific fields,types, etc. or just to skip linting of some of the schema part there is a lint
directive.
Directive definition looks like this:
directive @lint(
ignore: [String!]
except: [String!]
) on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ARGUMENT_DEFINITION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
ignore
parameter exists to define the list of the rules that are required to be skipped if fail on the defined place.
To ignore all the rules for something you can place lint directive without params or with empty ignore
list, like this:
type Book @lint {
title: String!
}
type TypeBook @lint(ignore: []) {
title: String!
}
Ignore some of the rules example:
type TypeBook @lint(ignore: ["INPUT_TYPE_SUFFIX", "ENUM_INPUT_SUFFIX"]) {
title: String!
}
except
parameter exists to define the list of the rules NOT to ignore and skip failing the step.
It might be useful to ignore all the rules for a particular place but except some specific set rules.
Following example will skip failing on linter step for all the configured rules except of the "INPUT_TYPE_SUFFIX" and "ENUM_INPUT_SUFFIX":
type TypeBook @lint(except: ["INPUT_TYPE_SUFFIX", "ENUM_INPUT_SUFFIX"]) {
title: String!
}
Available Linter Rules
Rule Name | Description |
---|---|
FIELD_NAMES_CAMEL_CASE | Field names should use only camelCase . |
INPUT_FIELD_NAMES_CAMEL_CASE | Input field names should use only camelCase . |
REST_FIELD_NAMES | Require field's name never to start from REST semantics verbs: get , list , post , put , patch . |
OBJECT_REQUIRE_ID | Require object types to have a field id: ID! . |
TYPE_NAMES_PASCAL_CASE | Every Objects, Interfaces, Inputs, Enums, Unions type names should use PascalCase . |
TYPE_PREFIX | Don't use the prefix Type in Objects, Interfaces, Inputs, Enums, Unions type's name. |
TYPE_SUFFIX | Don't use the suffix Type in Objects, Interfaces, Inputs, Enums, Unions type's name. |
OBJECT_PREFIX | Don't use the prefix Object in object type's name. |
OBJECT_SUFFIX | Don't use the suffix Object in object type's name. |
INTERFACE_PREFIX | Don't use the prefix Interface in interface type's name. |
INTERFACE_SUFFIX | Don't use the suffix Interface in interface type's name. |
INPUT_TYPE_SUFFIX | Always use suffix Input in input type's name. |
ENUM_VALUES_SCREAMING_SNAKE_CASE | Enum values should use only SCREAMING_SNAKE_CASE . |
ENUM_PREFIX | Don't use the prefix Enum in enum type's name. |
ENUM_SUFFIX | Don't use the suffix Enum in enum type's name. |
ENUM_INPUT_SUFFIX | Require enum type input argument to use the suffix Input in its name. |
ENUM_OUTPUT_SUFFIX | Require enum return type of a non-input field not to use the suffix Input . |
DIRECTIVE_NAMES_CAMEL_CASE | Require camelCase for directive names. |
ELEMENTS_DESCRIPTION | Require all elements in the schema to have description. |
DEPRECATED_DIRECTIVE_REASON | Require @deprecated directive to have reason argument. |
EVERY_TYPE_IS_REACHABLE | Each definition should be reachable. |
TYPE_SIMILARITY | Don't define similar types in the schema. |
FIELD_NAMES_CAMEL_CASE
Field names should use only camelCase
.
❌
type Actor {
FirstName: String! # PascalCase
}
✅
type Actor {
firstName: String # camelCase
}
INPUT_FIELD_NAMES_CAMEL_CASE
Input field names should use only camelCase
.
❌
input Actor {
FirstName: String! # PascalCase
}
✅
input Actor {
firstName: String # camelCase
}
REST_FIELD_NAMES
Require field's name never to start from REST semantics verbs: get
, list
, post
, put
, patch
.
❌
type Query {
getFilms: [Film!]!
}
✅
type Query {
films: [Film!]!
}
OBJECT_REQUIRE_ID
Require object types to have a field id: ID!
.
❌
type User {
name: String!
}
✅
type User {
id: ID!
name: String!
}
TYPE_NAMES_PASCAL_CASE
Every Objects, Interfaces, Inputs, Enums, Unions type names should use PascalCase
.
❌
type parentOrganization { # camelCase
id: ID!
}
✅
type ParentOrganization { # PascalCase
id: ID!
}
TYPE_PREFIX
Don't use the prefix Type
in Objects, Interfaces, Inputs, Enums, Unions type's name.
❌
type TypeBook {
title: String!
}
✅
type Book {
title: String!
}
TYPE_SUFFIX
Don't use the suffix Type
in Objects, Interfaces, Inputs, Enums, Unions type's name.
❌
type BookType {
title: String!
}
✅
type Book {
title: String!
}
OBJECT_PREFIX
Don't use the prefix Object
in object type's name.
❌
type ObjectBook {
title: String!
}
✅
type Book {
title: String!
}
OBJECT_SUFFIX
Don't use the suffix Object
in object type's name.
❌
type BookObject {
title: String!
}
✅
type Book {
title: String!
}
INTERFACE_PREFIX
Don't use the prefix Interface
in interface type's name.
❌
interface InterfaceBook {
title: String
author: String
}
✅
interface Book {
title: String
author: String
}
INTERFACE_SUFFIX
Don't use the suffix Interface
in interface type's name.
❌
interface BookInterface {
title: String
author: String
}
✅
interface Book {
title: String
author: String
}
INPUT_TYPE_SUFFIX
Always use suffix Input
in input type's name.
❌
input TweetDetails {
title: String!
content: String!
}
✅
input TweetDetailsInput {
title: String!
content: String!
}
ENUM_VALUES_SCREAMING_SNAKE_CASE
Enum values should use only SCREAMING_SNAKE_CASE
.
❌
enum Location {
public_park # snake_case
}
✅
enum Location {
PUBLIC_PARK # SCREAMING_SNAKE_CASE 😱
}
ENUM_PREFIX
Don't use the prefix Enum
in enum type's name.
❌
enum EnumGenres {
HOUSE
RNB
TRANCE
}
✅
enum Genres {
HOUSE
RNB
TRANCE
}
ENUM_SUFFIX
Don't use the suffix Enum
in enum type's name.
❌
enum GenresEnum {
HOUSE
RNB
TRANCE
}
✅
enum Genres {
HOUSE
RNB
TRANCE
}
ENUM_INPUT_SUFFIX
Require enum type input argument to use the suffix Input
in its name.
❌
enum Role {
OWNER
VIEWER
}
type Query {
users(role: Role): [User!]!
}
✅
enum RoleInput {
OWNER
VIEWER
}
type Query {
users(role: RoleInput): [User!]!
}
ENUM_OUTPUT_SUFFIX
Require enum return type of non-input field not to use the suffix Input
.
❌
enum CrewRoleInput {
EDITOR
VIEWER
}
type Query {
crewRole(crewId: ID!): CrewRoleInput
}
✅
enum CrewRole {
EDITOR
VIEWER
}
type Query {
crewRole(crewId: ID!): CrewRole
}
DIRECTIVE_NAMES_CAMEL_CASE
Require camelCase
for directive names.
❌
directive @SomeField on FIELD_DEFINITION # PascalCase
✅
directive @someField on FIELD_DEFINITION # camelCase
ELEMENTS_DESCRIPTION
Require all elements in the schema to have description.
❌
type Actor {
username: String!
}
✅
"Represents an actor"
type Actor {
"The actor's username"
username: String!
}
DEPRECATED_DIRECTIVE_REASON
Require @deprecated
directive to have reason
argument.
❌
type Film {
title: String!
name: String @deprecated
}
✅
type Film {
title: String!
name: String @deprecated(reason: "Use Film.title instead")
}
EVERY_TYPE_IS_REACHABLE
Each definition should be reachable.
❌
type Film {
title: String!
}
✅
type Query {
films: [Film!]!
}
type Film {
title: String!
}
TYPE_SIMILARITY
Don't define similar types in the schema.
❌
type Actor {
name: String!
}
type Film {
title: String!
actors: [Actor!]!
}
type Movie {
title: String!
actors: [Actor!]!
}
✅
type Actor {
name: String!
}
type Film {
title: String!
actors: [Actor!]!
}