Skip to content

Commit

Permalink
Bump io.micronaut.application from 3.7.10 to 4.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored and yannicklamprecht committed Jul 18, 2023
1 parent 6f9c46a commit 9f893a3
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 26 deletions.
6 changes: 4 additions & 2 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.1"
}

version = "2.0"
Expand All @@ -23,6 +23,7 @@ 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.8")
Expand All @@ -35,9 +36,10 @@ dependencies {
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("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

0 comments on commit 9f893a3

Please sign in to comment.