Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump io.micronaut.application from 3.7.10 to 4.0.x #216

Merged
merged 8 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ jobs:
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Build with Gradle
run: ./gradlew --build-cache build -x test

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand Down
15 changes: 12 additions & 3 deletions backend/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("com.github.johnrengelman.shadow") version "8.1.1"
id("io.micronaut.application") version "3.7.10"
id("io.micronaut.application") version "4.0.2"
}

version = "2.0"
Expand All @@ -23,21 +23,30 @@ dependencies {
annotationProcessor("io.micronaut.security:micronaut-security-annotations")
annotationProcessor("io.micronaut.data:micronaut-data-processor")
annotationProcessor("io.micronaut:micronaut-inject-java")
annotationProcessor("io.micronaut.validation:micronaut-validation-processor")
// When.MAYBE warning fix
annotationProcessor("com.google.code.findbugs:jsr305:3.0.2")
implementation("ch.qos.logback:logback-classic:1.4.11")
implementation("org.slf4j:slf4j-api:2.0.7")
implementation("com.google.code.findbugs:jsr305:3.0.2")
implementation("io.micronaut.security:micronaut-security-jwt")
implementation("io.micronaut.reactor:micronaut-reactor")
implementation("io.micronaut:micronaut-runtime")
implementation("io.micronaut.data:micronaut-data-jdbc")
implementation("io.micronaut.flyway:micronaut-flyway")
// https://github.com/flyway/flyway/issues/3651
implementation("org.flywaydb:flyway-core") {
version {
strictly("9.16.1")
}
}
implementation("io.micronaut.graphql:micronaut-graphql")
implementation("com.graphql-java-kickstart:graphql-java-tools:13.0.3")
implementation("com.graphql-java:graphql-java-extended-validation:20.0-validator-6.2.0.Final")
implementation("io.micronaut:micronaut-validation")
implementation("com.graphql-java:graphql-java-extended-validation:20.0")
implementation("io.micronaut.validation:micronaut-validation")
runtimeOnly("org.postgresql:postgresql")
runtimeOnly("io.micronaut.sql:micronaut-jdbc-hikari")
runtimeOnly("org.yaml:snakeyaml")

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.micronaut.security.authentication.Authentication;
import io.micronaut.security.token.jwt.validator.JwtTokenValidator;
import jakarta.inject.Singleton;
import java.security.Principal;
import java.util.regex.Pattern;
import reactor.core.publisher.Mono;

Expand All @@ -35,7 +36,10 @@ public UserIdValidator(JwtTokenValidator validator) {
}

public UserId validateUserIdFromToken(String token) {
return Mono.from(validator.validateToken(token, null))

Mono<Authentication> authenticationMono = Mono.<Authentication>from(validator.validateToken(token, null));

return authenticationMono
.map(Authentication::getName)
.mapNotNull(this::validateUserId)
.block();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import io.micronaut.data.annotation.Relation;
import io.micronaut.data.annotation.Relation.Cascade;
import io.micronaut.data.annotation.Relation.Kind;
import io.micronaut.data.jdbc.annotation.ColumnTransformer;
import io.micronaut.data.annotation.sql.ColumnTransformer;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import io.micronaut.data.annotation.MappedProperty;
import io.micronaut.data.annotation.Relation;
import io.micronaut.data.annotation.Relation.Kind;
import io.micronaut.data.jdbc.annotation.ColumnTransformer;
import io.micronaut.data.annotation.sql.ColumnTransformer;

@GraphQLType("User")
@MappedEntity("users")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import jakarta.inject.Singleton;
import java.sql.PreparedStatement;
import java.util.List;
import javax.transaction.Transactional;
import jakarta.transaction.Transactional;
import org.flywaydb.core.Flyway;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,21 @@
import io.micronaut.data.annotation.Join.Type;
import io.micronaut.data.annotation.Query;
import io.micronaut.data.jdbc.annotation.JdbcRepository;
import io.micronaut.data.model.query.builder.sql.Dialect;
import io.micronaut.data.repository.CrudRepository;
import java.util.List;
import java.util.Optional;
import org.jetbrains.annotations.NotNull;

@JdbcRepository
@JdbcRepository(dialect = Dialect.POSTGRES)
public interface TemplateRepo extends CrudRepository<Template, Integer> {

boolean existsByName(String name);

@Override
@IgnoreWhere
@Join(value = "questions", type = Type.LEFT_FETCH)
Optional<Template> findById(@javax.validation.constraints.NotNull Integer integer);
Optional<Template> findById(@jakarta.validation.constraints.NotNull Integer integer);

@Executable
@Join(value = "questions", type = Type.LEFT_FETCH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

import io.micronaut.configuration.graphql.GraphQLConfiguration;
import io.micronaut.configuration.graphql.GraphQLJsonSerializer;
import io.micronaut.configuration.graphql.ws.GraphQLWsConfiguration;
import io.micronaut.configuration.graphql.ws.GraphQLWsController;
import io.micronaut.configuration.graphql.ws.GraphQLWsRequest.ClientType;
import io.micronaut.configuration.graphql.ws.GraphQLWsResponse;
import io.micronaut.configuration.graphql.ws.apollo.GraphQLApolloWsConfiguration;
import io.micronaut.configuration.graphql.ws.apollo.GraphQLApolloWsController;
import io.micronaut.configuration.graphql.ws.apollo.GraphQLApolloWsRequest.ClientType;
import io.micronaut.configuration.graphql.ws.apollo.GraphQLApolloWsResponse;
import io.micronaut.http.HttpRequest;
import io.micronaut.websocket.CloseReason;
import io.micronaut.websocket.WebSocketSession;
Expand All @@ -33,15 +33,15 @@
import java.util.Map;
import org.reactivestreams.Publisher;

@ServerWebSocket(value = "${" + GraphQLConfiguration.PREFIX + "." + GraphQLWsConfiguration.PATH + ":"
+ GraphQLWsConfiguration.DEFAULT_PATH + "}", subprotocols = "graphql-ws")
@ServerWebSocket(value = "${" + GraphQLConfiguration.PREFIX + "." + GraphQLApolloWsConfiguration.PATH_CONFIG + ":"
+ GraphQLApolloWsConfiguration.DEFAULT_PATH + "}", subprotocols = "graphql-ws")
public class CustomGraphQLWsController {

private final GraphQLWsController controller;
private final GraphQLApolloWsController controller;
private final GraphQLJsonSerializer serializer;
private final SessionMetaData sessionMetaData;

public CustomGraphQLWsController(GraphQLWsController controller, GraphQLJsonSerializer serializer,
public CustomGraphQLWsController(GraphQLApolloWsController controller, GraphQLJsonSerializer serializer,
SessionMetaData sessionMetaData) {
this.controller = controller;
this.serializer = serializer;
Expand All @@ -54,7 +54,7 @@ public void onOpen(WebSocketSession session, HttpRequest<?> request) {
}

@OnMessage
public Publisher<GraphQLWsResponse> onMessage(String message, WebSocketSession session) {
public Publisher<GraphQLApolloWsResponse> onMessage(String message, WebSocketSession session) {
var type = serializer.deserialize(message, MessageType.class);
var request = session.get("httpRequest", HttpRequest.class).get();
if (ClientType.GQL_CONNECTION_INIT.getType().equals(type.type())) {
Expand All @@ -67,12 +67,12 @@ public Publisher<GraphQLWsResponse> onMessage(String message, WebSocketSession s
}

@OnClose
public Publisher<GraphQLWsResponse> onClose(WebSocketSession session, CloseReason closeReason) {
public Publisher<GraphQLApolloWsResponse> onClose(WebSocketSession session, CloseReason closeReason) {
return controller.onClose(session, closeReason);
}

@OnError
public Publisher<GraphQLWsResponse> onError(WebSocketSession session, Throwable t) {
public Publisher<GraphQLApolloWsResponse> onError(WebSocketSession session, Throwable t) {
return controller.onError(session, t);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package club.devcord.devmarkt.ws;

import club.devcord.devmarkt.entities.auth.UserId;
import io.micronaut.configuration.graphql.ws.GraphQLWsRequest;
import io.micronaut.configuration.graphql.ws.GraphQLWsResponse;
import io.micronaut.configuration.graphql.ws.apollo.GraphQLApolloWsRequest;
import io.micronaut.configuration.graphql.ws.apollo.GraphQLApolloWsResponse;
import io.micronaut.context.BeanContext;
import io.micronaut.websocket.WebSocketSession;
import jakarta.inject.Singleton;
Expand All @@ -36,7 +36,7 @@ public class ReflectiveUnsubscriber{
public ReflectiveUnsubscriber(BeanContext beanContext, SessionMetaData metaData) {
this.metaData = metaData;
try {
var stateClazz = Class.forName("io.micronaut.configuration.graphql.ws.GraphQLWsState");
var stateClazz = Class.forName("io.micronaut.configuration.graphql.ws.apollo.GraphQLApolloWsState");
this.wsState = beanContext.getBean(stateClazz);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
Expand All @@ -53,13 +53,13 @@ public void unsubscribeSubscriptions(UserId userId) {
var operationIdsField = activeOperations.getClass().getDeclaredField("activeOperations");
operationIdsField.setAccessible(true);
var operationIds = ((Map<String, ?>) operationIdsField.get(activeOperations)).keySet();
var method = wsState.getClass().getDeclaredMethod("stopOperation", GraphQLWsRequest.class,
var method = wsState.getClass().getDeclaredMethod("stopOperation", GraphQLApolloWsRequest.class,
WebSocketSession.class);
method.setAccessible(true);
for (var id : operationIds) {
var request = new GraphQLWsRequest();
var request = new GraphQLApolloWsRequest();
request.setId(id);
Flux.from((Publisher<GraphQLWsResponse>) method.invoke(wsState, request, session))
Flux.from((Publisher<GraphQLApolloWsResponse>) method.invoke(wsState, request, session))
.subscribe(session::sendSync);
}
} catch (Throwable e) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
micronautVersion=3.9.4
micronautVersion=4.0.0