Skip to content

Commit f84cbde

Browse files
authored
Merge pull request #503 from federicorispo/fix/bump-graphql-java-dependency
2 parents c9b00eb + 592c6bc commit f84cbde

File tree

8 files changed

+45
-30
lines changed

8 files changed

+45
-30
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PROJECT_LICENSE=MIT
77
PROJECT_LICENSE_URL=https://github.com/graphql-java-kickstart/spring-java-servlet/blob/master/LICENSE.md
88
PROJECT_DEV_ID=oliemansm
99
PROJECT_DEV_NAME=Michiel Oliemans
10-
LIB_GRAPHQL_JAVA_VER=19.3
10+
LIB_GRAPHQL_JAVA_VER=20.0
1111
LIB_JACKSON_VER=2.14.2
1212
LIB_SLF4J_VER=2.0.6
1313
LIB_LOMBOK_VER=1.18.26

graphql-java-kickstart/src/main/java/graphql/kickstart/execution/GraphQLQueryInvoker.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import graphql.execution.instrumentation.ChainedInstrumentation;
44
import graphql.execution.instrumentation.Instrumentation;
5-
import graphql.execution.instrumentation.SimpleInstrumentation;
5+
import graphql.execution.instrumentation.SimplePerformantInstrumentation;
66
import graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentationOptions;
77
import graphql.execution.preparsed.NoOpPreparsedDocumentProvider;
88
import graphql.execution.preparsed.PreparsedDocumentProvider;
@@ -12,7 +12,9 @@
1212
import java.util.List;
1313
import java.util.function.Supplier;
1414

15-
/** @author Andrew Potter */
15+
/**
16+
* @author Andrew Potter
17+
*/
1618
public class GraphQLQueryInvoker {
1719

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

4951
private Supplier<ExecutionStrategyProvider> getExecutionStrategyProvider =
5052
DefaultExecutionStrategyProvider::new;
51-
private Supplier<Instrumentation> getInstrumentation = () -> SimpleInstrumentation.INSTANCE;
53+
private Supplier<Instrumentation> getInstrumentation =
54+
() -> SimplePerformantInstrumentation.INSTANCE;
5255
private Supplier<PreparsedDocumentProvider> getPreparsedDocumentProvider =
5356
() -> NoOpPreparsedDocumentProvider.INSTANCE;
5457
private Supplier<DataLoaderDispatcherInstrumentationOptions>

graphql-java-kickstart/src/main/java/graphql/kickstart/execution/config/GraphQLBuilder.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import graphql.execution.ExecutionStrategy;
55
import graphql.execution.instrumentation.ChainedInstrumentation;
66
import graphql.execution.instrumentation.Instrumentation;
7-
import graphql.execution.instrumentation.SimpleInstrumentation;
7+
import graphql.execution.instrumentation.SimplePerformantInstrumentation;
88
import graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentation;
99
import graphql.execution.preparsed.NoOpPreparsedDocumentProvider;
1010
import graphql.execution.preparsed.PreparsedDocumentProvider;
@@ -20,7 +20,8 @@ public class GraphQLBuilder {
2020
() -> NoOpPreparsedDocumentProvider.INSTANCE;
2121

2222
@Getter
23-
private Supplier<Instrumentation> instrumentationSupplier = () -> SimpleInstrumentation.INSTANCE;
23+
private Supplier<Instrumentation> instrumentationSupplier =
24+
() -> SimplePerformantInstrumentation.INSTANCE;
2425

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

graphql-java-kickstart/src/main/java/graphql/kickstart/execution/instrumentation/ConfigurableDispatchInstrumentation.java

+24-13
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,17 @@ public InstrumentationState createState(InstrumentationCreateStateParameters par
6464

6565
@Override
6666
public DataFetcher<?> instrumentDataFetcher(
67-
DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters) {
68-
DataLoaderDispatcherInstrumentationState state = parameters.getInstrumentationState();
67+
DataFetcher<?> dataFetcher,
68+
InstrumentationFieldFetchParameters parameters,
69+
InstrumentationState instrumentationState) {
70+
DataLoaderDispatcherInstrumentationState state =
71+
InstrumentationState.ofState(instrumentationState);
6972
if (state.isAggressivelyBatching()) {
7073
return dataFetcher;
7174
}
7275
//
7376
// currently only AsyncExecutionStrategy with DataLoader and hence this allows us to "dispatch"
74-
// on every object if its not using aggressive batching for other execution strategies
77+
// on every object if it's not using aggressive batching for other execution strategies
7578
// which allows them to work if used.
7679
return (DataFetcher<Object>)
7780
environment -> {
@@ -87,12 +90,14 @@ private void doImmediatelyDispatch(DataLoaderDispatcherInstrumentationState stat
8790

8891
@Override
8992
public InstrumentationContext<ExecutionResult> beginExecuteOperation(
90-
InstrumentationExecuteOperationParameters parameters) {
93+
InstrumentationExecuteOperationParameters parameters,
94+
InstrumentationState instrumentationState) {
9195
if (!isDataLoaderCompatible(parameters.getExecutionContext())) {
92-
DataLoaderDispatcherInstrumentationState state = parameters.getInstrumentationState();
96+
DataLoaderDispatcherInstrumentationState state =
97+
InstrumentationState.ofState(instrumentationState);
9398
state.setAggressivelyBatching(false);
9499
}
95-
return new SimpleInstrumentationContext<>();
100+
return SimpleInstrumentationContext.noOp();
96101
}
97102

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

112117
@Override
113118
public ExecutionStrategyInstrumentationContext beginExecutionStrategy(
114-
InstrumentationExecutionStrategyParameters parameters) {
115-
DataLoaderDispatcherInstrumentationState state = parameters.getInstrumentationState();
119+
InstrumentationExecutionStrategyParameters parameters,
120+
InstrumentationState instrumentationState) {
121+
DataLoaderDispatcherInstrumentationState state =
122+
InstrumentationState.ofState(instrumentationState);
116123
//
117124
// if there are no data loaders, there is nothing to do
118125
//
@@ -134,21 +141,25 @@ public void onCompleted(ExecutionResult result, Throwable t) {
134141

135142
@Override
136143
public InstrumentationContext<Object> beginFieldFetch(
137-
InstrumentationFieldFetchParameters parameters) {
138-
DataLoaderDispatcherInstrumentationState state = parameters.getInstrumentationState();
144+
InstrumentationFieldFetchParameters parameters, InstrumentationState instrumentationState) {
145+
DataLoaderDispatcherInstrumentationState state =
146+
InstrumentationState.ofState(instrumentationState);
139147
//
140148
// if there are no data loaders, there is nothing to do
141149
//
142150
if (state.hasNoDataLoaders()) {
143-
return new SimpleInstrumentationContext<>();
151+
return SimpleInstrumentationContext.noOp();
144152
}
145153
return state.getApproach().beginFieldFetch(parameters);
146154
}
147155

148156
@Override
149157
public CompletableFuture<ExecutionResult> instrumentExecutionResult(
150-
ExecutionResult executionResult, InstrumentationExecutionParameters parameters) {
151-
DataLoaderDispatcherInstrumentationState state = parameters.getInstrumentationState();
158+
ExecutionResult executionResult,
159+
InstrumentationExecutionParameters parameters,
160+
InstrumentationState instrumentationState) {
161+
DataLoaderDispatcherInstrumentationState state =
162+
InstrumentationState.ofState(instrumentationState);
152163
state.getApproach().removeTracking(parameters.getExecutionInput().getExecutionId());
153164
if (!options.isIncludeStatistics()) {
154165
return CompletableFuture.completedFuture(executionResult);
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package graphql.kickstart.execution.instrumentation;
22

33
import graphql.execution.instrumentation.Instrumentation;
4-
import graphql.execution.instrumentation.SimpleInstrumentation;
4+
import graphql.execution.instrumentation.SimplePerformantInstrumentation;
55
import graphql.kickstart.execution.config.InstrumentationProvider;
66

77
public class NoOpInstrumentationProvider implements InstrumentationProvider {
88

99
@Override
1010
public Instrumentation getInstrumentation() {
11-
return SimpleInstrumentation.INSTANCE;
11+
return SimplePerformantInstrumentation.INSTANCE;
1212
}
1313
}

graphql-java-servlet/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dependencies {
2929
compileOnly 'org.osgi:org.osgi.service.metatype.annotations:1.4.1'
3030
compileOnly 'org.osgi:org.osgi.annotation:6.0.0'
3131

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

3434
// Unit testing
3535
testImplementation "org.apache.groovy:groovy-all:4.0.10"

graphql-java-servlet/src/test/groovy/graphql/kickstart/servlet/DataLoaderDispatchingSpec.groovy

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
44
import graphql.ExecutionInput
55
import graphql.execution.instrumentation.ChainedInstrumentation
66
import graphql.execution.instrumentation.Instrumentation
7-
import graphql.execution.instrumentation.SimpleInstrumentation
7+
import graphql.execution.instrumentation.SimplePerformantInstrumentation
88
import graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentationOptions
99
import graphql.kickstart.execution.context.ContextSetting
1010
import graphql.kickstart.execution.context.DefaultGraphQLContext
@@ -14,7 +14,7 @@ import graphql.kickstart.servlet.context.GraphQLServletContextBuilder
1414
import graphql.schema.DataFetcher
1515
import graphql.schema.DataFetchingEnvironment
1616
import org.dataloader.BatchLoader
17-
import org.dataloader.DataLoader
17+
import org.dataloader.DataLoaderFactory
1818
import org.dataloader.DataLoaderRegistry
1919
import org.springframework.mock.web.MockHttpServletRequest
2020
import org.springframework.mock.web.MockHttpServletResponse
@@ -59,9 +59,9 @@ class DataLoaderDispatchingSpec extends Specification {
5959

6060
def registry() {
6161
DataLoaderRegistry registry = new DataLoaderRegistry()
62-
registry.register("A", DataLoader.newDataLoader(batchLoaderWithCounter(fetchCounterA)))
63-
registry.register("B", DataLoader.newDataLoader(batchLoaderWithCounter(fetchCounterB)))
64-
registry.register("C", DataLoader.newDataLoader(batchLoaderWithCounter(fetchCounterC)))
62+
registry.register("A", DataLoaderFactory.newDataLoader(batchLoaderWithCounter(fetchCounterA)))
63+
registry.register("B", DataLoaderFactory.newDataLoader(batchLoaderWithCounter(fetchCounterB)))
64+
registry.register("C", DataLoaderFactory.newDataLoader(batchLoaderWithCounter(fetchCounterC)))
6565
registry
6666
}
6767

@@ -120,7 +120,7 @@ class DataLoaderDispatchingSpec extends Specification {
120120
mapper.readValue(response.getContentAsByteArray(), List)
121121
}
122122

123-
Instrumentation simpleInstrumentation = new SimpleInstrumentation()
123+
Instrumentation simpleInstrumentation = new SimplePerformantInstrumentation()
124124
ChainedInstrumentation chainedInstrumentation = new ChainedInstrumentation(Collections.singletonList(simpleInstrumentation))
125125
def simpleSupplier = { simpleInstrumentation }
126126
def chainedSupplier = { chainedInstrumentation }

graphql-java-servlet/src/test/groovy/graphql/kickstart/servlet/OsgiGraphQLHttpServletSpec.groovy

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import graphql.annotations.annotationTypes.GraphQLField
55
import graphql.annotations.annotationTypes.GraphQLName
66
import graphql.annotations.processor.GraphQLAnnotations
77
import graphql.execution.instrumentation.InstrumentationState
8-
import graphql.execution.instrumentation.SimpleInstrumentation
8+
import graphql.execution.instrumentation.SimplePerformantInstrumentation
99
import graphql.execution.instrumentation.parameters.InstrumentationCreateStateParameters
1010
import graphql.kickstart.execution.GraphQLRequest
1111
import graphql.kickstart.execution.config.ExecutionStrategyProvider
@@ -349,7 +349,7 @@ class OsgiGraphQLHttpServletSpec extends Specification {
349349
def "instrumentation provider is bound and unbound"() {
350350
setup:
351351
def servlet = new OsgiGraphQLHttpServlet()
352-
def instrumentation = new SimpleInstrumentation()
352+
def instrumentation = new SimplePerformantInstrumentation()
353353
def instrumentationProvider = Mock(InstrumentationProvider)
354354
instrumentationProvider.getInstrumentation() >> instrumentation
355355
def request = GraphQLRequest.createIntrospectionRequest()

0 commit comments

Comments
 (0)