Skip to content

Commit 6cb906d

Browse files
Update to graphql-java 19.0 (#1491)
FlowSubscriptionExecutionStrategy needs to be updated to pass instrumentationState to instrumentations per graphql-java/graphql-java#2769 ValidationError string changed slightly so adjust assertions.
1 parent 87e1412 commit 6cb906d

File tree

6 files changed

+37
-17
lines changed

6 files changed

+37
-17
lines changed

examples/server/spring-server/src/test/kotlin/com/expediagroup/graphql/examples/server/spring/WebTestClientExtensions.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.expediagroup.graphql.examples.server.spring
1818

19+
import org.hamcrest.core.StringContains
1920
import org.springframework.test.web.reactive.server.WebTestClient
2021

2122
fun WebTestClient.ResponseSpec.verifyOnlyDataExists(expectedQuery: String): WebTestClient.BodyContentSpec {
@@ -34,10 +35,14 @@ fun WebTestClient.ResponseSpec.verifyData(
3435
.jsonPath("$DATA_JSON_PATH.$expectedQuery").isEqualTo(expectedData)
3536
}
3637

37-
fun WebTestClient.ResponseSpec.verifyError(expectedError: String): WebTestClient.BodyContentSpec {
38+
fun WebTestClient.ResponseSpec.verifyError(expectedErrorSubString: String): WebTestClient.BodyContentSpec {
3839
return this.expectStatus().isOk
3940
.expectBody()
40-
.jsonPath(DATA_JSON_PATH).doesNotExist()
41-
.jsonPath("$ERRORS_JSON_PATH.[0].message").isEqualTo(expectedError)
41+
.verifyError(expectedErrorSubString)
42+
}
43+
44+
fun WebTestClient.BodyContentSpec.verifyError(expectedErrorSubString: String): WebTestClient.BodyContentSpec {
45+
return this.jsonPath(DATA_JSON_PATH).doesNotExist()
46+
.jsonPath("$ERRORS_JSON_PATH.[0].message").value(StringContains.containsString(expectedErrorSubString))
4247
.jsonPath(EXTENSIONS_JSON_PATH).doesNotExist()
4348
}

examples/server/spring-server/src/test/kotlin/com/expediagroup/graphql/examples/server/spring/query/PolymorphicQueryIT.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ class PolymorphicQueryIT(@Autowired private val testClient: WebTestClient) {
8181
.bodyValue("query { $query(type: $unknownType) { type, sound } }")
8282
.exchange()
8383
.expectStatus().isOk
84+
.verifyError("Validation error")
85+
.verifyError("WrongType")
8486
.verifyError(
85-
"Validation error of type WrongType: " +
86-
"argument 'type' with value 'EnumValue{name='$unknownType'}' is not a valid 'AnimalType' - " +
87-
"Expected enum literal value not in allowable values - 'EnumValue{name='HELLO'}'. @ 'animal'"
87+
"argument 'type' with value 'EnumValue{name='$unknownType'}' is not a valid 'AnimalType' - " +
88+
"Expected enum literal value not in allowable values - 'EnumValue{name='HELLO'}'"
8889
)
8990
}
9091

examples/server/spring-server/src/test/kotlin/com/expediagroup/graphql/examples/server/spring/query/SimpleQueryIT.kt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,31 +73,37 @@ class SimpleQueryIT(@Autowired private val testClient: WebTestClient) {
7373
@Test
7474
fun `verify notPartOfSchema query`() {
7575
val query = "notPartOfSchema"
76-
val expectedError = "Validation error of type FieldUndefined: " +
77-
"Field 'notPartOfSchema' in type 'Query' is undefined @ 'notPartOfSchema'"
76+
val expectedErrorOne = "Validation error"
77+
val expectedErrorTwo = "FieldUndefined"
78+
val expectedErrorThree = "Field 'notPartOfSchema' in type 'Query' is undefined"
7879

7980
testClient.post()
8081
.uri(GRAPHQL_ENDPOINT)
8182
.accept(APPLICATION_JSON)
8283
.contentType(GRAPHQL_MEDIA_TYPE)
8384
.bodyValue("query { $query }")
8485
.exchange()
85-
.verifyError(expectedError)
86+
.verifyError(expectedErrorOne)
87+
.verifyError(expectedErrorTwo)
88+
.verifyError(expectedErrorThree)
8689
}
8790

8891
@Test
8992
fun `verify privateFunctionsAreNotVisible query`() {
9093
val query = "privateFunctionsAreNotVisible"
91-
val expectedError = "Validation error of type FieldUndefined: " +
92-
"Field 'privateFunctionsAreNotVisible' in type 'Query' is undefined @ 'privateFunctionsAreNotVisible'"
94+
val expectedErrorOne = "Validation error"
95+
val expectedErrorTwo = "FieldUndefined"
96+
val expectedErrorThree = "Field 'privateFunctionsAreNotVisible' in type 'Query' is undefined"
9397

9498
testClient.post()
9599
.uri(GRAPHQL_ENDPOINT)
96100
.accept(APPLICATION_JSON)
97101
.contentType(GRAPHQL_MEDIA_TYPE)
98102
.bodyValue("query { $query }")
99103
.exchange()
100-
.verifyError(expectedError)
104+
.verifyError(expectedErrorOne)
105+
.verifyError(expectedErrorTwo)
106+
.verifyError(expectedErrorThree)
101107
}
102108

103109
@Test

generator/graphql-kotlin-schema-generator/src/main/kotlin/com/expediagroup/graphql/generator/execution/FlowSubscriptionExecutionStrategy.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import graphql.execution.ExecutionStrategy
2525
import graphql.execution.ExecutionStrategyParameters
2626
import graphql.execution.SimpleDataFetcherExceptionHandler
2727
import graphql.execution.SubscriptionExecutionStrategy
28+
import graphql.execution.instrumentation.ExecutionStrategyInstrumentationContext
29+
import graphql.execution.instrumentation.SimpleInstrumentationContext
2830
import graphql.execution.instrumentation.parameters.InstrumentationExecutionParameters
2931
import graphql.execution.instrumentation.parameters.InstrumentationExecutionStrategyParameters
3032
import graphql.execution.instrumentation.parameters.InstrumentationFieldParameters
@@ -55,7 +57,9 @@ class FlowSubscriptionExecutionStrategy(dfe: DataFetcherExceptionHandler) : Exec
5557

5658
val instrumentation = executionContext.instrumentation
5759
val instrumentationParameters = InstrumentationExecutionStrategyParameters(executionContext, parameters)
58-
val executionStrategyCtx = instrumentation.beginExecutionStrategy(instrumentationParameters)
60+
val executionStrategyCtx = ExecutionStrategyInstrumentationContext.nonNullCtx(
61+
instrumentation.beginExecutionStrategy(instrumentationParameters, executionContext.instrumentationState)
62+
)
5963

6064
val sourceEventStream = createSourceEventStream(executionContext, parameters)
6165

@@ -142,7 +146,9 @@ class FlowSubscriptionExecutionStrategy(dfe: DataFetcherExceptionHandler) : Exec
142146
val subscribedFieldStepInfo = createSubscribedFieldStepInfo(executionContext, newParameters)
143147

144148
val i13nFieldParameters = InstrumentationFieldParameters(executionContext) { subscribedFieldStepInfo }
145-
val subscribedFieldCtx = instrumentation.beginSubscribedFieldEvent(i13nFieldParameters)
149+
val subscribedFieldCtx = SimpleInstrumentationContext.nonNullCtx(
150+
instrumentation.beginSubscribedFieldEvent(i13nFieldParameters, executionContext.instrumentationState)
151+
)
146152

147153
val fetchedValue = unboxPossibleDataFetcherResult(newExecutionContext, parameters, eventPayload)
148154

@@ -161,7 +167,7 @@ class FlowSubscriptionExecutionStrategy(dfe: DataFetcherExceptionHandler) : Exec
161167
)
162168

163169
return overallResult.thenCompose { executionResult ->
164-
instrumentation.instrumentExecutionResult(executionResult, i13ExecutionParameters)
170+
instrumentation.instrumentExecutionResult(executionResult, i13ExecutionParameters, executionContext.instrumentationState)
165171
}
166172
}
167173

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ kotlinxSerializationVersion = 1.3.2
2222
androidPluginVersion = 7.1.2
2323
classGraphVersion = 4.8.143
2424
federationGraphQLVersion = 0.9.0
25-
graphQLJavaVersion = 18.0
25+
graphQLJavaVersion = 19.0
2626
graphQLJavaDataLoaderVersion = 3.1.3
2727
jacksonVersion = 2.13.2
2828
kotlinPoetVersion = 1.11.0

servers/graphql-kotlin-spring-server/src/test/kotlin/com/expediagroup/graphql/server/spring/execution/IntrospectionIT.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package com.expediagroup.graphql.server.spring.execution
1818
import com.expediagroup.graphql.server.operations.Query
1919
import com.expediagroup.graphql.server.types.GraphQLRequest
2020
import graphql.introspection.IntrospectionQuery
21+
import org.hamcrest.core.StringContains
2122
import org.junit.jupiter.api.Test
2223
import org.springframework.beans.factory.annotation.Autowired
2324
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
@@ -50,7 +51,8 @@ class IntrospectionIT(@Autowired private val testClient: WebTestClient) {
5051
.expectBody()
5152
.jsonPath("$.data").doesNotExist()
5253
.jsonPath("$.errors").isArray
53-
.jsonPath("$.errors[0].message").isEqualTo("Validation error of type FieldUndefined: Field 'queryType' in type '__Schema' is undefined @ '__schema/queryType'")
54+
.jsonPath("$.errors[0].message").value(StringContains.containsString("Validation error"))
55+
.jsonPath("$.errors[0].message").value(StringContains.containsString("Field 'queryType' in type '__Schema' is undefined"))
5456
}
5557

5658
@Configuration

0 commit comments

Comments
 (0)