elguardian commented on code in PR #1962: URL: https://github.com/apache/incubator-kie-kogito-apps/pull/1962#discussion_r1465974787
########## data-audit/kogito-addons-data-audit-quarkus/src/main/java/org/kie/kogito/app/audit/quarkus/GraphQLDataAuditRouter.java: ########## @@ -0,0 +1,129 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.kogito.app.audit.quarkus; + +import org.kie.kogito.app.audit.api.DataAuditQuery; +import org.kie.kogito.app.audit.api.DataAuditQueryService; +import org.kie.kogito.app.audit.api.DataAuditStoreProxyService; +import org.kie.kogito.app.audit.graphql.GraphQLSchemaBuild; +import org.kie.kogito.app.audit.spi.DataAuditContextFactory; + +import io.quarkus.vertx.web.Route; +import io.vertx.core.json.JsonObject; +import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.handler.graphql.ExecutionInputBuilderWithContext; +import io.vertx.ext.web.handler.graphql.GraphQLHandler; +import io.vertx.ext.web.handler.graphql.GraphQLHandlerOptions; + +import graphql.GraphQL; +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Status; +import jakarta.transaction.Synchronization; +import jakarta.transaction.TransactionSynchronizationRegistry; +import jakarta.transaction.Transactional; + +import static io.quarkus.vertx.web.Route.HttpMethod.GET; +import static io.quarkus.vertx.web.Route.HttpMethod.POST; +import static org.kie.kogito.app.audit.api.SubsystemConstants.DATA_AUDIT_QUERY_PATH; +import static org.kie.kogito.app.audit.api.SubsystemConstants.DATA_AUDIT_REGISTRY_PATH; +import static org.kie.kogito.app.audit.graphql.GraphQLSchemaManager.graphQLSchemaManagerInstance; + +@ApplicationScoped +@Transactional +public class GraphQLDataAuditRouter { + + GraphQL graphQL; + + GraphQLHandler graphQLHandler; + + @Inject + DataAuditContextFactory dataAuditContextFactory; + + private DataAuditQueryService dataAuditQueryService; + + private DataAuditStoreProxyService dataAuditStoreProxyService; + + @Inject + TransactionSynchronizationRegistry registry; + + @PostConstruct + public void init() { + graphQLSchemaManagerInstance().init(dataAuditContextFactory.newDataAuditContext()); + dataAuditQueryService = DataAuditQueryService.newAuditQuerySerice(); + dataAuditStoreProxyService = DataAuditStoreProxyService.newAuditStoreService(); + graphQLHandler = GraphQLHandler.create(dataAuditQueryService.getGraphQL(), new GraphQLHandlerOptions()); + } + + @Route(path = DATA_AUDIT_QUERY_PATH, type = Route.HandlerType.BLOCKING, order = 2, methods = { GET }) + public void blockingGraphQLHandlerGet(RoutingContext rc) { Review Comment: we needed a way to verify that graphQL schema. If you add a new graphql query we needed a way to know the schema as it is build dynamically. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
