Skip to content

fix(deps): update graphql-java to v20.0.0 #503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PROJECT_LICENSE=MIT
PROJECT_LICENSE_URL=https://github.com/graphql-java-kickstart/spring-java-servlet/blob/master/LICENSE.md
PROJECT_DEV_ID=oliemansm
PROJECT_DEV_NAME=Michiel Oliemans
LIB_GRAPHQL_JAVA_VER=19.3
LIB_GRAPHQL_JAVA_VER=20.0
LIB_JACKSON_VER=2.14.2
LIB_SLF4J_VER=2.0.6
LIB_LOMBOK_VER=1.18.26
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import graphql.execution.instrumentation.ChainedInstrumentation;
import graphql.execution.instrumentation.Instrumentation;
import graphql.execution.instrumentation.SimpleInstrumentation;
import graphql.execution.instrumentation.SimplePerformantInstrumentation;
import graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentationOptions;
import graphql.execution.preparsed.NoOpPreparsedDocumentProvider;
import graphql.execution.preparsed.PreparsedDocumentProvider;
Expand All @@ -12,7 +12,9 @@
import java.util.List;
import java.util.function.Supplier;

/** @author Andrew Potter */
/**
* @author Andrew Potter
*/
public class GraphQLQueryInvoker {

private final Supplier<ExecutionStrategyProvider> getExecutionStrategyProvider;
Expand Down Expand Up @@ -48,7 +50,8 @@ public static class Builder {

private Supplier<ExecutionStrategyProvider> getExecutionStrategyProvider =
DefaultExecutionStrategyProvider::new;
private Supplier<Instrumentation> getInstrumentation = () -> SimpleInstrumentation.INSTANCE;
private Supplier<Instrumentation> getInstrumentation =
() -> SimplePerformantInstrumentation.INSTANCE;
private Supplier<PreparsedDocumentProvider> getPreparsedDocumentProvider =
() -> NoOpPreparsedDocumentProvider.INSTANCE;
private Supplier<DataLoaderDispatcherInstrumentationOptions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import graphql.execution.ExecutionStrategy;
import graphql.execution.instrumentation.ChainedInstrumentation;
import graphql.execution.instrumentation.Instrumentation;
import graphql.execution.instrumentation.SimpleInstrumentation;
import graphql.execution.instrumentation.SimplePerformantInstrumentation;
import graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentation;
import graphql.execution.preparsed.NoOpPreparsedDocumentProvider;
import graphql.execution.preparsed.PreparsedDocumentProvider;
Expand All @@ -20,7 +20,8 @@ public class GraphQLBuilder {
() -> NoOpPreparsedDocumentProvider.INSTANCE;

@Getter
private Supplier<Instrumentation> instrumentationSupplier = () -> SimpleInstrumentation.INSTANCE;
private Supplier<Instrumentation> instrumentationSupplier =
() -> SimplePerformantInstrumentation.INSTANCE;

private Supplier<GraphQLBuilderConfigurer> graphQLBuilderConfigurerSupplier = () -> builder -> {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,17 @@ public InstrumentationState createState(InstrumentationCreateStateParameters par

@Override
public DataFetcher<?> instrumentDataFetcher(
DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters) {
DataLoaderDispatcherInstrumentationState state = parameters.getInstrumentationState();
DataFetcher<?> dataFetcher,
InstrumentationFieldFetchParameters parameters,
InstrumentationState instrumentationState) {
DataLoaderDispatcherInstrumentationState state =
InstrumentationState.ofState(instrumentationState);
if (state.isAggressivelyBatching()) {
return dataFetcher;
}
//
// currently only AsyncExecutionStrategy with DataLoader and hence this allows us to "dispatch"
// on every object if its not using aggressive batching for other execution strategies
// on every object if it's not using aggressive batching for other execution strategies
// which allows them to work if used.
return (DataFetcher<Object>)
environment -> {
Expand All @@ -87,12 +90,14 @@ private void doImmediatelyDispatch(DataLoaderDispatcherInstrumentationState stat

@Override
public InstrumentationContext<ExecutionResult> beginExecuteOperation(
InstrumentationExecuteOperationParameters parameters) {
InstrumentationExecuteOperationParameters parameters,
InstrumentationState instrumentationState) {
if (!isDataLoaderCompatible(parameters.getExecutionContext())) {
DataLoaderDispatcherInstrumentationState state = parameters.getInstrumentationState();
DataLoaderDispatcherInstrumentationState state =
InstrumentationState.ofState(instrumentationState);
state.setAggressivelyBatching(false);
}
return new SimpleInstrumentationContext<>();
return SimpleInstrumentationContext.noOp();
}

private boolean isDataLoaderCompatible(ExecutionContext executionContext) {
Expand All @@ -111,8 +116,10 @@ private boolean isDataLoaderCompatible(ExecutionContext executionContext) {

@Override
public ExecutionStrategyInstrumentationContext beginExecutionStrategy(
InstrumentationExecutionStrategyParameters parameters) {
DataLoaderDispatcherInstrumentationState state = parameters.getInstrumentationState();
InstrumentationExecutionStrategyParameters parameters,
InstrumentationState instrumentationState) {
DataLoaderDispatcherInstrumentationState state =
InstrumentationState.ofState(instrumentationState);
//
// if there are no data loaders, there is nothing to do
//
Expand All @@ -134,21 +141,25 @@ public void onCompleted(ExecutionResult result, Throwable t) {

@Override
public InstrumentationContext<Object> beginFieldFetch(
InstrumentationFieldFetchParameters parameters) {
DataLoaderDispatcherInstrumentationState state = parameters.getInstrumentationState();
InstrumentationFieldFetchParameters parameters, InstrumentationState instrumentationState) {
DataLoaderDispatcherInstrumentationState state =
InstrumentationState.ofState(instrumentationState);
//
// if there are no data loaders, there is nothing to do
//
if (state.hasNoDataLoaders()) {
return new SimpleInstrumentationContext<>();
return SimpleInstrumentationContext.noOp();
}
return state.getApproach().beginFieldFetch(parameters);
}

@Override
public CompletableFuture<ExecutionResult> instrumentExecutionResult(
ExecutionResult executionResult, InstrumentationExecutionParameters parameters) {
DataLoaderDispatcherInstrumentationState state = parameters.getInstrumentationState();
ExecutionResult executionResult,
InstrumentationExecutionParameters parameters,
InstrumentationState instrumentationState) {
DataLoaderDispatcherInstrumentationState state =
InstrumentationState.ofState(instrumentationState);
state.getApproach().removeTracking(parameters.getExecutionInput().getExecutionId());
if (!options.isIncludeStatistics()) {
return CompletableFuture.completedFuture(executionResult);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package graphql.kickstart.execution.instrumentation;

import graphql.execution.instrumentation.Instrumentation;
import graphql.execution.instrumentation.SimpleInstrumentation;
import graphql.execution.instrumentation.SimplePerformantInstrumentation;
import graphql.kickstart.execution.config.InstrumentationProvider;

public class NoOpInstrumentationProvider implements InstrumentationProvider {

@Override
public Instrumentation getInstrumentation() {
return SimpleInstrumentation.INSTANCE;
return SimplePerformantInstrumentation.INSTANCE;
}
}
2 changes: 1 addition & 1 deletion graphql-java-servlet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies {
compileOnly 'org.osgi:org.osgi.service.metatype.annotations:1.4.1'
compileOnly 'org.osgi:org.osgi.annotation:6.0.0'

testImplementation 'io.github.graphql-java:graphql-java-annotations:8.3'
testImplementation 'io.github.graphql-java:graphql-java-annotations:9.1'

// Unit testing
testImplementation "org.apache.groovy:groovy-all:4.0.10"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
import graphql.ExecutionInput
import graphql.execution.instrumentation.ChainedInstrumentation
import graphql.execution.instrumentation.Instrumentation
import graphql.execution.instrumentation.SimpleInstrumentation
import graphql.execution.instrumentation.SimplePerformantInstrumentation
import graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentationOptions
import graphql.kickstart.execution.context.ContextSetting
import graphql.kickstart.execution.context.DefaultGraphQLContext
Expand All @@ -14,7 +14,7 @@ import graphql.kickstart.servlet.context.GraphQLServletContextBuilder
import graphql.schema.DataFetcher
import graphql.schema.DataFetchingEnvironment
import org.dataloader.BatchLoader
import org.dataloader.DataLoader
import org.dataloader.DataLoaderFactory
import org.dataloader.DataLoaderRegistry
import org.springframework.mock.web.MockHttpServletRequest
import org.springframework.mock.web.MockHttpServletResponse
Expand Down Expand Up @@ -59,9 +59,9 @@ class DataLoaderDispatchingSpec extends Specification {

def registry() {
DataLoaderRegistry registry = new DataLoaderRegistry()
registry.register("A", DataLoader.newDataLoader(batchLoaderWithCounter(fetchCounterA)))
registry.register("B", DataLoader.newDataLoader(batchLoaderWithCounter(fetchCounterB)))
registry.register("C", DataLoader.newDataLoader(batchLoaderWithCounter(fetchCounterC)))
registry.register("A", DataLoaderFactory.newDataLoader(batchLoaderWithCounter(fetchCounterA)))
registry.register("B", DataLoaderFactory.newDataLoader(batchLoaderWithCounter(fetchCounterB)))
registry.register("C", DataLoaderFactory.newDataLoader(batchLoaderWithCounter(fetchCounterC)))
registry
}

Expand Down Expand Up @@ -120,7 +120,7 @@ class DataLoaderDispatchingSpec extends Specification {
mapper.readValue(response.getContentAsByteArray(), List)
}

Instrumentation simpleInstrumentation = new SimpleInstrumentation()
Instrumentation simpleInstrumentation = new SimplePerformantInstrumentation()
ChainedInstrumentation chainedInstrumentation = new ChainedInstrumentation(Collections.singletonList(simpleInstrumentation))
def simpleSupplier = { simpleInstrumentation }
def chainedSupplier = { chainedInstrumentation }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import graphql.annotations.annotationTypes.GraphQLField
import graphql.annotations.annotationTypes.GraphQLName
import graphql.annotations.processor.GraphQLAnnotations
import graphql.execution.instrumentation.InstrumentationState
import graphql.execution.instrumentation.SimpleInstrumentation
import graphql.execution.instrumentation.SimplePerformantInstrumentation
import graphql.execution.instrumentation.parameters.InstrumentationCreateStateParameters
import graphql.kickstart.execution.GraphQLRequest
import graphql.kickstart.execution.config.ExecutionStrategyProvider
Expand Down Expand Up @@ -349,7 +349,7 @@ class OsgiGraphQLHttpServletSpec extends Specification {
def "instrumentation provider is bound and unbound"() {
setup:
def servlet = new OsgiGraphQLHttpServlet()
def instrumentation = new SimpleInstrumentation()
def instrumentation = new SimplePerformantInstrumentation()
def instrumentationProvider = Mock(InstrumentationProvider)
instrumentationProvider.getInstrumentation() >> instrumentation
def request = GraphQLRequest.createIntrospectionRequest()
Expand Down