Skip to content

Commit

Permalink
Remove usage of NoOpPreparsedDocumentProvider
Browse files Browse the repository at this point in the history
NoOpPreparsedDocumentProvider is marked as internal in graphql-java; however, it is
the default PreparsedDocumentProvider used by the GraphQL.Builder, so we can use it
by virtue of simply not passing anything in when no PreparsedDocumentProvider bean
is available.
  • Loading branch information
kilink committed Apr 19, 2022
1 parent 1c18387 commit 782a2a5
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import graphql.execution.ExecutionIdProvider
import graphql.execution.ExecutionStrategy
import graphql.execution.NonNullableFieldWasNullError
import graphql.execution.instrumentation.Instrumentation
import graphql.execution.preparsed.NoOpPreparsedDocumentProvider
import graphql.execution.preparsed.PreparsedDocumentProvider
import graphql.schema.GraphQLSchema
import org.slf4j.Logger
Expand All @@ -54,7 +53,7 @@ class DefaultDgsReactiveQueryExecutor(
private val mutationExecutionStrategy: ExecutionStrategy,
private val idProvider: Optional<ExecutionIdProvider>,
private val reloadIndicator: DefaultDgsQueryExecutor.ReloadSchemaIndicator = DefaultDgsQueryExecutor.ReloadSchemaIndicator { false },
private val preparsedDocumentProvider: PreparsedDocumentProvider = NoOpPreparsedDocumentProvider.INSTANCE,
private val preparsedDocumentProvider: PreparsedDocumentProvider? = null,
private val queryValueCustomizer: QueryValueCustomizer = QueryValueCustomizer { query -> query }
) : com.netflix.graphql.dgs.reactive.DgsReactiveQueryExecutor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import graphql.execution.ExecutionIdProvider
import graphql.execution.ExecutionStrategy
import graphql.execution.instrumentation.ChainedInstrumentation
import graphql.execution.instrumentation.Instrumentation
import graphql.execution.preparsed.NoOpPreparsedDocumentProvider
import graphql.execution.preparsed.PreparsedDocumentProvider
import graphql.schema.DataFetcherFactory
import graphql.schema.GraphQLCodeRegistry
Expand Down Expand Up @@ -86,7 +85,7 @@ open class DgsAutoConfiguration(
@Qualifier("mutation") providedMutationExecutionStrategy: Optional<ExecutionStrategy>,
idProvider: Optional<ExecutionIdProvider>,
reloadSchemaIndicator: ReloadSchemaIndicator,
preparsedDocumentProvider: PreparsedDocumentProvider,
preparsedDocumentProvider: ObjectProvider<PreparsedDocumentProvider>,
queryValueCustomizer: QueryValueCustomizer
): DgsQueryExecutor {
val queryExecutionStrategy =
Expand All @@ -111,7 +110,7 @@ open class DgsAutoConfiguration(
mutationExecutionStrategy = mutationExecutionStrategy,
idProvider = idProvider,
reloadIndicator = reloadSchemaIndicator,
preparsedDocumentProvider = preparsedDocumentProvider,
preparsedDocumentProvider = preparsedDocumentProvider.ifAvailable,
queryValueCustomizer = queryValueCustomizer
)
}
Expand All @@ -122,12 +121,6 @@ open class DgsAutoConfiguration(
return QueryValueCustomizer { a -> a }
}

@Bean
@ConditionalOnMissingBean
open fun preparsedDocumentProvider(): PreparsedDocumentProvider {
return NoOpPreparsedDocumentProvider.INSTANCE
}

@Bean
open fun dgsDataLoaderProvider(applicationContext: ApplicationContext): DgsDataLoaderProvider {
return DgsDataLoaderProvider(applicationContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ open class DgsWebFluxAutoConfiguration(private val configProps: DgsWebfluxConfig
@Qualifier("mutation") providedMutationExecutionStrategy: Optional<ExecutionStrategy>,
idProvider: Optional<ExecutionIdProvider>,
reloadSchemaIndicator: DefaultDgsQueryExecutor.ReloadSchemaIndicator,
preparsedDocumentProvider: PreparsedDocumentProvider,
preparsedDocumentProvider: ObjectProvider<PreparsedDocumentProvider>,
queryValueCustomizer: QueryValueCustomizer
): DgsReactiveQueryExecutor {

Expand All @@ -117,7 +117,7 @@ open class DgsWebFluxAutoConfiguration(private val configProps: DgsWebfluxConfig
mutationExecutionStrategy = mutationExecutionStrategy,
idProvider = idProvider,
reloadIndicator = reloadSchemaIndicator,
preparsedDocumentProvider = preparsedDocumentProvider,
preparsedDocumentProvider = preparsedDocumentProvider.ifAvailable,
queryValueCustomizer = queryValueCustomizer
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ object BaseDgsQueryExecutor {
queryExecutionStrategy: ExecutionStrategy,
mutationExecutionStrategy: ExecutionStrategy,
idProvider: Optional<ExecutionIdProvider>,
preparsedDocumentProvider: PreparsedDocumentProvider,
preparsedDocumentProvider: PreparsedDocumentProvider?,
): CompletableFuture<ExecutionResult> {

if (!StringUtils.hasText(query)) {
Expand All @@ -89,10 +89,10 @@ object BaseDgsQueryExecutor {

val graphQLBuilder =
GraphQL.newGraphQL(graphQLSchema)
.preparsedDocumentProvider(preparsedDocumentProvider)
.queryExecutionStrategy(queryExecutionStrategy)
.mutationExecutionStrategy(mutationExecutionStrategy)

preparsedDocumentProvider?.let { graphQLBuilder.preparsedDocumentProvider(it) }
instrumentation?.let { graphQLBuilder.instrumentation(it) }
idProvider.ifPresent { graphQLBuilder.executionIdProvider(it) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import graphql.execution.ExecutionIdProvider
import graphql.execution.ExecutionStrategy
import graphql.execution.NonNullableFieldWasNullError
import graphql.execution.instrumentation.Instrumentation
import graphql.execution.preparsed.NoOpPreparsedDocumentProvider
import graphql.execution.preparsed.PreparsedDocumentProvider
import graphql.schema.GraphQLSchema
import org.slf4j.Logger
Expand All @@ -53,7 +52,7 @@ class DefaultDgsQueryExecutor(
private val mutationExecutionStrategy: ExecutionStrategy,
private val idProvider: Optional<ExecutionIdProvider>,
private val reloadIndicator: ReloadSchemaIndicator = ReloadSchemaIndicator { false },
private val preparsedDocumentProvider: PreparsedDocumentProvider = NoOpPreparsedDocumentProvider.INSTANCE,
private val preparsedDocumentProvider: PreparsedDocumentProvider? = null,
private val queryValueCustomizer: QueryValueCustomizer = QueryValueCustomizer { query -> query }
) : DgsQueryExecutor {

Expand Down

0 comments on commit 782a2a5

Please sign in to comment.