yahoo / elide

Elide is a Java library that lets you stand up a GraphQL/JSON-API web service with minimal effort.
https://elide.io
Other
1k stars 228 forks source link

Fix async when graphql not enabled #3246

Closed justin-tay closed 2 months ago

justin-tay commented 3 months ago

Resolves #3245

Description

This adds a AsyncProviderService that is injected into the AsyncExecutorService to decouple the AsyncExecutorService implementation from the JsonApi and QueryRunners implementations. These are now registered into the AsyncProviderService.

The AsyncQueryOperation implementations then get the providers that they need in the following manner.

JsonApi jsonApi = getService().getProviders().getProvider(JsonApi.class);
QueryRunners queryRunners = getService().getProviders().getProvider(QueryRunners.class);

Motivation and Context

This fixes the bug where an exception is thrown when elide.async.enabled is true and elide.graphql.enabled is false.

This also allows the elide-graphql dependency to be excluded without errors if GraphQL is not required.

How Has This Been Tested?

A asyncEnabledJsonApiEnabledGraphqlNotEnabled test was added to ElideAutoConfigurationTest.

This was also tested manually with the elide-spring-boot-example by manually excluding the elide-graphql dependency and exercising the asyncQuery and tableExport functionality.

License

I confirm that this contribution is made under an Apache 2.0 license and that I have the authority necessary to make this contribution on behalf of its copyright owner.