elguardian commented on code in PR #1962:
URL: 
https://github.com/apache/incubator-kie-kogito-apps/pull/1962#discussion_r1464619641


##########
data-audit/data-audit-common/src/main/java/org/kie/kogito/app/audit/api/SubsystemConstants.java:
##########
@@ -25,6 +25,8 @@ private SubsystemConstants() {
     }
 
     public static final String DATA_AUDIT_PATH = "/data-audit";
+    public static final String DATA_AUDIT_QUERY_PATH = "/data-audit/q";

Review Comment:
   changed



##########
data-audit/data-audit-common/src/main/java/org/kie/kogito/app/audit/api/SubsystemConstants.java:
##########
@@ -25,6 +25,8 @@ private SubsystemConstants() {
     }
 
     public static final String DATA_AUDIT_PATH = "/data-audit";
+    public static final String DATA_AUDIT_QUERY_PATH = "/data-audit/q";
+    public static final String DATA_AUDIT_REGISTRY_PATH = "/data-audit/r";

Review Comment:
   changed



##########
data-audit/data-audit-common/src/main/java/org/kie/kogito/app/audit/graphql/GraphQLSchemaManager.java:
##########
@@ -103,22 +125,52 @@ private GraphQLSchemaManager() {
         SchemaGenerator schemaGenerator = new SchemaGenerator();
         // we merge the query object
         
typeDefinitionRegistry.add(ObjectTypeDefinition.newObjectTypeDefinition().name("Query").fieldDefinitions(queryDefinitions).build());
-        graphQLSchema = 
schemaGenerator.makeExecutableSchema(typeDefinitionRegistry, runtimeWiring);
+        GraphQLSchema newGraphQLSchema = 
schemaGenerator.makeExecutableSchema(typeDefinitionRegistry, runtimeWiring);
+        GraphQL newGraphQL = GraphQL.newGraphQL(newGraphQLSchema).build();
 
+        // we got to this point then everything is validated
+        this.graphQLSchema = newGraphQLSchema;
+        this.graphQL = newGraphQL;
+        LOGGER.debug("Succesfuly rebuilding graphQL definitions");
     }
 
-    private TypeDefinitionRegistry readDefintionRegistry(String graphQLSchema) 
{
-        try (InputStream is = 
Thread.currentThread().getContextClassLoader().getResourceAsStream(graphQLSchema))
 {
-            SchemaParser schemaParser = new SchemaParser();
-            return schemaParser.parse(is);
+    private InputStream toInputStream(String classpathFile) {
+        try (InputStream is = 
Thread.currentThread().getContextClassLoader().getResourceAsStream(classpathFile))
 {
+            return new ByteArrayInputStream(is.readAllBytes());
         } catch (IOException e) {
             LOGGER.error("could not find or process {}", graphQLSchema, e);
-            return new TypeDefinitionRegistry();
+            return new ByteArrayInputStream(new byte[0]);
         }
     }
 
+    private TypeDefinitionRegistry readDefintionRegistry(InputStream 
inputStream) {

Review Comment:
   changed



##########
data-audit/data-audit-common/src/main/java/org/kie/kogito/app/audit/graphql/GraphQLSchemaManager.java:
##########
@@ -77,14 +95,18 @@ private GraphQLSchemaManager() {
 
         ServiceLoader.load(GraphQLSchemaQueryProvider.class, 
classLoader).forEach(queryProvider -> {
             
graphqlSchemas.addAll(List.of(queryProvider.graphQLQueryExtension()));
-            for (GraphQLSchemaQuery<?> query : queryProvider.queries()) {
+            for (GraphQLSchemaQuery query : 
queryProvider.queries(dataAuditContext)) {
                 runtimeWiringBuilder.type("Query", builder -> 
builder.dataFetcher(query.name(), query::fetch));
             }
         });
 
+        List<InputStream> data = new ArrayList<>();
+        
data.addAll(graphqlSchemas.stream().map(this::toInputStream).collect(Collectors.toList()));

Review Comment:
   changed



##########
data-audit/data-audit-common/src/main/java/org/kie/kogito/app/audit/graphql/GraphQLSchemaManager.java:
##########
@@ -77,14 +95,18 @@ private GraphQLSchemaManager() {
 
         ServiceLoader.load(GraphQLSchemaQueryProvider.class, 
classLoader).forEach(queryProvider -> {
             
graphqlSchemas.addAll(List.of(queryProvider.graphQLQueryExtension()));
-            for (GraphQLSchemaQuery<?> query : queryProvider.queries()) {
+            for (GraphQLSchemaQuery query : 
queryProvider.queries(dataAuditContext)) {
                 runtimeWiringBuilder.type("Query", builder -> 
builder.dataFetcher(query.name(), query::fetch));
             }
         });
 
+        List<InputStream> data = new ArrayList<>();
+        
data.addAll(graphqlSchemas.stream().map(this::toInputStream).collect(Collectors.toList()));
+        
data.addAll(this.graphQLdefinitions.values().stream().map(String::getBytes).map(ByteArrayInputStream::new).collect(Collectors.toList()));

Review Comment:
   changed



-- 
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]

Reply via email to