This package structure is based on multiple sources of best practices in Spring Boot, using roughly the "Package by layer" approach.
- root
- config
- controller
- dapr
- dto
- exception
- persistence
- dao
- mapper
- repository
- service
- validation
The detailed package structure is documented here.
We use the default Oracle Styleguide, i.e., the default settings of IntelliJ, as a base. Also remember the Java naming conventions.
- If acronyms are used in class, variable, or other names, only the first letter of the acronym should be capitalized, all other letters must not be capitalized, e.g.
AbstractJsonToXmlConverter
Please regard the GraphQL naming conventions
To validate the input the microservice receives on the field level, we can use a set of predefined graphQL directives. Example:
input CreateCourseInput {
# Title of the course, max 255 characters
title: String! @NotBlank @Size(max: 255)
# Description of the course, max 3000 characters
description: String! @Size(max: 3000)
...
}
This will automatically raise a graphQL error if for example the title
in this example is blank.
More information on these directives here
To validate an input class on class level, e.g., to check if a start date is before an end date or there are no duplicate items in the db, write your custom validation code in the validation
package and call it in the corresponding service class.
Services follow the naming schema: "servicename_service".