File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
main/java/graphql/incremental
test/groovy/graphql/incremental Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 10
10
import java .util .LinkedList ;
11
11
import java .util .List ;
12
12
import java .util .Map ;
13
+ import java .util .function .Consumer ;
13
14
import java .util .stream .Collectors ;
14
15
15
16
@ ExperimentalApi
@@ -52,6 +53,13 @@ public static Builder fromExecutionResult(ExecutionResult executionResult) {
52
53
return new Builder ().from (executionResult );
53
54
}
54
55
56
+ @ Override
57
+ public IncrementalExecutionResult transform (Consumer <ExecutionResult .Builder <?>> builderConsumer ) {
58
+ var builder = fromExecutionResult (this );
59
+ builderConsumer .accept (builder );
60
+ return builder .build ();
61
+ }
62
+
55
63
@ Override
56
64
public Map <String , Object > toSpecification () {
57
65
Map <String , Object > map = new LinkedHashMap <>(super .toSpecification ());
Original file line number Diff line number Diff line change 1
1
package graphql.incremental
2
2
3
3
import graphql.execution.ResultPath
4
- import groovy.json.JsonOutput
5
4
import io.reactivex.Flowable
6
- import org.reactivestreams.Publisher
7
5
import spock.lang.Specification
8
6
9
7
import static graphql.incremental.DeferPayload.newDeferredItem
@@ -120,4 +118,18 @@ class IncrementalExecutionResultTest extends Specification {
120
118
newIncrementalExecutionResult. hasNext() == incrementalExecutionResult. hasNext()
121
119
newIncrementalExecutionResult. toSpecification() == incrementalExecutionResult. toSpecification()
122
120
}
121
+
122
+ def " transform returns IncrementalExecutionResult" () {
123
+ when :
124
+ def initial = newIncrementalExecutionResult(). hasNext(true ). build()
125
+
126
+ then :
127
+ def transformed = initial. transform { b ->
128
+ b. addExtension(" ext-key" , " ext-value" )
129
+ b. hasNext(false )
130
+ }
131
+ transformed instanceof IncrementalExecutionResult
132
+ transformed. extensions == [" ext-key" : " ext-value" ]
133
+ transformed. hasNext == false
134
+ }
123
135
}
You can’t perform that action at this time.
0 commit comments