From 03d8a1827b99a8d49c9f2e732b3a51293f1715fb Mon Sep 17 00:00:00 2001 From: myluki2000 Date: Thu, 4 Sep 2025 16:16:23 +0200 Subject: [PATCH] update meitrex-common --- build.gradle | 5 +- ...phQlScalarsAndValidationConfiguration.java | 35 ------ src/main/resources/application.properties | 2 + .../graphql/common/directives.graphqls | 23 ---- .../resources/graphql/common/scalars.graphqls | 12 -- .../common/sortFilterPagination.graphqls | 104 ------------------ src/test/resources/application.properties | 4 +- 7 files changed, 8 insertions(+), 177 deletions(-) delete mode 100644 src/main/java/de/unistuttgart/iste/meitrex/user_service/config/GraphQlScalarsAndValidationConfiguration.java delete mode 100644 src/main/resources/graphql/common/directives.graphqls delete mode 100644 src/main/resources/graphql/common/scalars.graphqls delete mode 100644 src/main/resources/graphql/common/sortFilterPagination.graphqls diff --git a/build.gradle b/build.gradle index c09d0cf..ef929da 100644 --- a/build.gradle +++ b/build.gradle @@ -57,6 +57,7 @@ graphqlCodegen { packageName = "de.unistuttgart.iste.meitrex.generated.dto" generatedAnnotation = "jakarta.annotation.Generated" modelValidationAnnotation = "jakarta.validation.constraints.NotNull" + generateJacksonTypeIdResolver = true // allows graphql .toEntity() conversion with Jackson for interfaces and unions generateApis = false // set to false as the generator does not support spring boot graphQL customTypesMapping = [ "DateTime" : "java.time.OffsetDateTime", @@ -109,7 +110,7 @@ repositories { dependencies { implementation("com.google.code.gson:gson:2.10.1") - implementation 'de.unistuttgart.iste.meitrex:meitrex-common:1.3.3' + implementation 'de.unistuttgart.iste.meitrex:meitrex-common:1.4.6' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-graphql' implementation 'org.springframework.boot:spring-boot-starter-validation' @@ -126,7 +127,7 @@ dependencies { runtimeOnly 'org.postgresql:postgresql' annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' annotationProcessor 'org.projectlombok:lombok' - testImplementation 'de.unistuttgart.iste.meitrex:meitrex-common-test:1.3.3' + testImplementation 'de.unistuttgart.iste.meitrex:meitrex-common-test:1.4.6' testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework:spring-webflux' testImplementation 'org.springframework.graphql:spring-graphql-test' diff --git a/src/main/java/de/unistuttgart/iste/meitrex/user_service/config/GraphQlScalarsAndValidationConfiguration.java b/src/main/java/de/unistuttgart/iste/meitrex/user_service/config/GraphQlScalarsAndValidationConfiguration.java deleted file mode 100644 index e0f1a64..0000000 --- a/src/main/java/de/unistuttgart/iste/meitrex/user_service/config/GraphQlScalarsAndValidationConfiguration.java +++ /dev/null @@ -1,35 +0,0 @@ -package de.unistuttgart.iste.meitrex.user_service.config; - -import graphql.scalars.ExtendedScalars; -import graphql.validation.rules.OnValidationErrorStrategy; -import graphql.validation.rules.ValidationRules; -import graphql.validation.schemawiring.ValidationSchemaWiring; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.graphql.execution.RuntimeWiringConfigurer; - -/** - * This class sets up the validation rules for the GraphQL schema and the scalar types. - */ -@Configuration -public class GraphQlScalarsAndValidationConfiguration { - - @Bean - public RuntimeWiringConfigurer runtimeWiringConfigurer() { - - ValidationRules validationRules = ValidationRules.newValidationRules() - .onValidationErrorStrategy(OnValidationErrorStrategy.RETURN_NULL) - .build(); - - ValidationSchemaWiring schemaWiring = new ValidationSchemaWiring(validationRules); - - return wiringBuilder -> wiringBuilder - .directiveWiring(schemaWiring) - .scalar(ExtendedScalars.DateTime) - .scalar(ExtendedScalars.Date) - .scalar(ExtendedScalars.Time) - .scalar(ExtendedScalars.LocalTime) - .scalar(ExtendedScalars.UUID) - .scalar(ExtendedScalars.Url); - } -} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 86a9efe..a144a4f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -24,6 +24,8 @@ keycloak.clientId=admin-cli keycloak.masterRealm=master keycloak.realm=GITS +spring.graphql.schema.locations=classpath*:graphql/common/**/,classpath:graphql/** + # URL to exchange the code for a token and refresh token thirdparty.providers.github.tokenRequestUrl=https://github.com/login/oauth/access_token # URL to get the user information from GitHub based on the token diff --git a/src/main/resources/graphql/common/directives.graphqls b/src/main/resources/graphql/common/directives.graphqls deleted file mode 100644 index 5b85062..0000000 --- a/src/main/resources/graphql/common/directives.graphqls +++ /dev/null @@ -1,23 +0,0 @@ -# see also https://github.com/graphql-java/graphql-java-extended-validation/blob/master/README.md - -directive @DecimalMax(value : String!, inclusive : Boolean! = true, message : String = "graphql.validation.DecimalMax.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @DecimalMin(value : String!, inclusive : Boolean! = true, message : String = "graphql.validation.DecimalMin.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @Max(value : Int! = 2147483647, message : String = "graphql.validation.Max.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @Min(value : Int! = 0, message : String = "graphql.validation.Min.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @Negative(message : String = "graphql.validation.Negative.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @NegativeOrZero(message : String = "graphql.validation.NegativeOrZero.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @NotBlank(message : String = "graphql.validation.NotBlank.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @NotEmpty(message : String = "graphql.validation.NotEmpty.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @ContainerNotEmpty(message : String = "graphql.validation.ContainerNotEmpty.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @Pattern(regexp : String! =".*", message : String = "graphql.validation.Pattern.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @Positive(message : String = "graphql.validation.Positive.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @PositiveOrZero(message : String = "graphql.validation.PositiveOrZero.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @Range(min : Int = 0, max : Int = 2147483647, message : String = "graphql.validation.Range.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @Size(min : Int = 0, max : Int = 2147483647, message : String = "graphql.validation.Size.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @ContainerSize(min : Int = 0, max : Int = 2147483647, message : String = "graphql.validation.ContainerSize.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION - -""" -The @OnDemand directive is used to mark fields that are only internally resolved when requested. -Implementation Note: This will cause the code generator to omit the field from the generated DTOs. -""" -directive @OnDemand on FIELD_DEFINITION \ No newline at end of file diff --git a/src/main/resources/graphql/common/scalars.graphqls b/src/main/resources/graphql/common/scalars.graphqls deleted file mode 100644 index d5da038..0000000 --- a/src/main/resources/graphql/common/scalars.graphqls +++ /dev/null @@ -1,12 +0,0 @@ -# will be mapped to OffsetDateTime in Java -scalar DateTime @specifiedBy(url: "https://scalars.graphql.org/andimarek/date-time.html") -# will be mapped to LocalDate in Java -scalar Date @specifiedBy(url:"https://tools.ietf.org/html/rfc3339") -# will be mapped to OffsetTime in Java -scalar Time @specifiedBy(url:"https://tools.ietf.org/html/rfc3339") -# will be mapped to LocalTime in Java -scalar LocalTime -# will be mapped to UUID in Java -scalar UUID @specifiedBy(url: "https://tools.ietf.org/html/rfc4122") -# will be mapped to URL in Java -scalar Url @specifiedBy(url:"https://www.w3.org/Addressing/URL/url-spec.txt") \ No newline at end of file diff --git a/src/main/resources/graphql/common/sortFilterPagination.graphqls b/src/main/resources/graphql/common/sortFilterPagination.graphqls deleted file mode 100644 index 67e1d26..0000000 --- a/src/main/resources/graphql/common/sortFilterPagination.graphqls +++ /dev/null @@ -1,104 +0,0 @@ -""" -Specifies the sort direction, either ascending or descending. -""" -enum SortDirection { - ASC - DESC -} - -""" -Specifies the page size and page number for paginated results. -""" -input Pagination { - """ - The page number, starting at 0. - If not specified, the default value is 0. - For values greater than 0, the page size must be specified. - If this value is larger than the number of pages, an empty page is returned. - """ - page: Int! = 0 @PositiveOrZero - """ - The number of elements per page. - """ - size: Int! @Positive -} - -""" -Return type for information about paginated results. -""" -type PaginationInfo { - """ - The current page number. - """ - page: Int! - """ - The number of elements per page. - """ - size: Int! - """ - The total number of elements across all pages. - """ - totalElements: Int! - """ - The total number of pages. - """ - totalPages: Int! - """ - Whether there is a next page. - """ - hasNext: Boolean! -} - -""" -Filter for string values. -If multiple filters are specified, they are combined with AND. -""" -input StringFilter { - """ - A string value to match exactly. - """ - equals: String - """ - A string value that must be contained in the field that is being filtered. - """ - contains: String - """ - If true, the filter is case-insensitive. - """ - ignoreCase: Boolean! = false -} - -""" -Filter for integer values. -If multiple filters are specified, they are combined with AND. -""" -input IntFilter { - """ - An integer value to match exactly. - """ - equals: Int - """ - If specified, filters for values greater than to the specified value. - """ - greaterThan: Int - """ - If specified, filters for values less than to the specified value. - """ - lessThan: Int -} - -""" -Filter for date values. -If multiple filters are specified, they are combined with AND. -""" -input DateTimeFilter { - """ - If specified, filters for dates after the specified value. - """ - after: DateTime - """ - If specified, filters for dates before the specified value. - """ - before: DateTime -} - diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index e2cd32e..e74e066 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -1,4 +1,6 @@ spring.datasource.url=jdbc:tc:postgresql:///user-service spring.datasource.username=root spring.datasource.password=root -spring.jpa.hibernate.ddl-auto=create \ No newline at end of file +spring.jpa.hibernate.ddl-auto=create + +spring.graphql.schema.locations=classpath*:graphql/common/**/,classpath:graphql/** \ No newline at end of file