pefernan commented on code in PR #1962:
URL:
https://github.com/apache/incubator-kie-kogito-apps/pull/1962#discussion_r1465288783
##########
data-audit/data-audit-common/src/main/java/org/kie/kogito/app/audit/graphql/GraphQLSchemaManager.java:
##########
@@ -103,22 +124,61 @@ 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();
+ LOGGER.debug("Succesfuly rebuilding graphQL definitions");
+ return new GraphQLSchemaBuild(newGraphQLSchema, newGraphQL,
additionalDefinitions);
}
- 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 readDefinitionRegistry(InputStream
inputStream) {
+ SchemaParser schemaParser = new SchemaParser();
+ return schemaParser.parse(inputStream);
+ }
+
+ public GraphQL getGraphQL() {
+ return graphQL;
+ }
+
public GraphQLSchema getGraphQLSchema() {
return graphQLSchema;
}
+ public ExecutionResult execute(ExecutionInput executionInput) {
+ return graphQL.execute(executionInput);
+ }
+
+ public String getGraphQLSchemaDefinition() {
+ SchemaPrinter printer = new SchemaPrinter();
+ return printer.print(graphQL.getGraphQLSchema());
+ }
+
+ public void init(DataAuditContext dataAuditContext) {
+ setGraphQLSchemaBuild(rebuildDefinitions(dataAuditContext, new
HashMap<>()));
+ }
+
+ public GraphQLSchemaBuild registerQuery(DataAuditContext dataAuditContext,
DataAuditQuery dataAuditQuery) {
Review Comment:
@elguardian I'd rename this method to something like
`buildDataAuditQuerySchema` or similar since it's no longer doing registering
the query.
--
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]