Merged PR 223498: fix(ExecutionInput): support null query when runnin… · graphql-java/graphql-java@4ec1d23
@@ -8,6 +8,7 @@ import graphql.execution.instrumentation.InstrumentationState
88import graphql.execution.instrumentation.parameters.InstrumentationExecutionStrategyParameters
99import graphql.execution.instrumentation.parameters.InstrumentationFieldCompleteParameters
1010import graphql.execution.instrumentation.parameters.InstrumentationFieldParameters
11+import graphql.execution.preparsed.persisted.PersistedQuerySupport
1112import graphql.schema.DataFetcher
1213import graphql.schema.DataFetchingEnvironment
1314import org.dataloader.DataLoaderRegistry
@@ -45,6 +46,21 @@ class ExecutionInputTest extends Specification {
4546 executionInput.query == query
4647 executionInput.locale == Locale.GERMAN
4748 executionInput.extensions == [some: "map"]
49+ executionInput.toString() != null
50+ }
51+52+def "build without locale"() {
53+when:
54+def executionInput = ExecutionInput.newExecutionInput().query(query)
55+ .dataLoaderRegistry(registry)
56+ .variables(variables)
57+ .root(root)
58+ .graphQLContext({ it.of(["a": "b"]) })
59+ .locale(null)
60+ .extensions([some: "map"])
61+ .build()
62+then:
63+ executionInput.locale == Locale.getDefault()
4864 }
49655066def "map context build works"() {
@@ -314,6 +330,33 @@ class ExecutionInputTest extends Specification {
314330 "1000 ms" | plusOrMinus(1000)
315331 }
316332333+ def "uses persisted query marker when query is null"() {
334+ when:
335+ ExecutionInput.newExecutionInput().query(null).build()
336+ then:
337+ thrown(AssertException)
338+ }
339+340+ def "uses persisted query marker when query is null and extensions contains persistedQuery"() {
341+ when:
342+ def executionInput = ExecutionInput.newExecutionInput()
343+ .extensions([persistedQuery: "any"])
344+ .query(null)
345+ .build()
346+ then:
347+ executionInput.query == PersistedQuerySupport.PERSISTED_QUERY_MARKER
348+ }
349+350+ def "uses persisted query marker when query is empty and extensions contains persistedQuery"() {
351+ when:
352+ def executionInput = ExecutionInput.newExecutionInput()
353+ .extensions([persistedQuery: "any"])
354+ .query("")
355+ .build()
356+ then:
357+ executionInput.query == PersistedQuerySupport.PERSISTED_QUERY_MARKER
358+ }
359+317360 def "can cancel at specific places"() {
318361 def sdl = '''
319362 type Query {