Skip to content

Commit

Permalink
[Fix #2165] Walters comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtirado committed Dec 20, 2024
1 parent 0970544 commit 9af8228
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
import org.kie.kogito.index.storage.DataIndexStorageService;
import org.kie.kogito.persistence.api.StorageFetcher;
import org.kie.kogito.persistence.api.query.Query;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import graphql.schema.GraphQLInputObjectType;
import graphql.schema.GraphQLNamedType;
Expand All @@ -68,6 +71,8 @@ public abstract class AbstractGraphQLSchemaManager implements GraphQLSchemaManag

private static final String UNABLE_TO_FIND_ERROR_MSG = "Unable to find the instance with %s %s";

private static final Logger LOGGER = LoggerFactory.getLogger(AbstractGraphQLSchemaManager.class);

@Inject
DataIndexStorageService cacheService;

Expand All @@ -84,6 +89,7 @@ public abstract class AbstractGraphQLSchemaManager implements GraphQLSchemaManag
@PostConstruct
public void setup() {
mutations = ServiceLoader.load(GraphQLMutationsProvider.class).stream().map(Provider::get).collect(Collectors.toList());

schema = createSchema();
GraphQLQueryParserRegistry.get().registerParsers(
(GraphQLInputObjectType) schema.getType("ProcessDefinitionArgument"),
Expand All @@ -93,8 +99,10 @@ public void setup() {
}

protected final void loadAdditionalMutations(Builder builder) {
mutations.stream().map(m -> m.mutations(this)).flatMap(map -> map.entrySet().stream())
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (v1, v2) -> v2)).forEach(builder::dataFetcher);
Map<String, DataFetcher<CompletableFuture<?>>> mutationMap = mutations.stream().map(m -> m.mutations(this)).flatMap(map -> map.entrySet().stream())
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (v1, v2) -> v2));
LOGGER.info("Custom mutations are {}", mutationMap);
mutationMap.forEach(builder::dataFetcher);
}

protected final void loadAdditionalMutations(TypeDefinitionRegistry typeRegistry) {
Expand Down

0 comments on commit 9af8228

Please sign in to comment.