File tree Expand file tree Collapse file tree
main/java/graphql/execution/incremental
test/groovy/graphql/execution/incremental Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -165,7 +165,7 @@ private Supplier<CompletableFuture<DeferredFragmentCall.FieldWithExecutionResult
165165
166166 return executionResultCF
167167 .thenApply (executionResult ->
168- new DeferredFragmentCall .FieldWithExecutionResult (currentField .getName (), executionResult )
168+ new DeferredFragmentCall .FieldWithExecutionResult (currentField .getResultKey (), executionResult )
169169 );
170170 }
171171 )
Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ private DeferPayload transformToDeferredPayload(List<FieldWithExecutionResult> f
107107 ImmutableList .Builder <GraphQLError > errorsBuilder = ImmutableList .builder ();
108108
109109 fieldWithExecutionResults .forEach (entry -> {
110- dataMap .put (entry .fieldName , entry .executionResult .getData ());
110+ dataMap .put (entry .resultKey , entry .executionResult .getData ());
111111 errorsBuilder .addAll (entry .executionResult .getErrors ());
112112 });
113113
@@ -120,11 +120,11 @@ private DeferPayload transformToDeferredPayload(List<FieldWithExecutionResult> f
120120 }
121121
122122 public static class FieldWithExecutionResult {
123- private final String fieldName ;
123+ private final String resultKey ;
124124 private final ExecutionResult executionResult ;
125125
126- public FieldWithExecutionResult (String fieldName , ExecutionResult executionResult ) {
127- this .fieldName = fieldName ;
126+ public FieldWithExecutionResult (String resultKey , ExecutionResult executionResult ) {
127+ this .resultKey = resultKey ;
128128 this .executionResult = executionResult ;
129129 }
130130
Original file line number Diff line number Diff line change @@ -201,6 +201,44 @@ class DeferExecutionSupportIntegrationTest extends Specification {
201201 ]
202202 }
203203
204+ def " defer with aliased fields" () {
205+ def query = '''
206+ query {
207+ postAlias: post {
208+ idAlias: id
209+ ... @defer {
210+ summaryAlias: summary
211+ }
212+ }
213+ }
214+ '''
215+
216+ when :
217+ IncrementalExecutionResult initialResult = executeQuery(query)
218+
219+ then :
220+ initialResult. toSpecification() == [
221+ data : [postAlias : [idAlias : " 1001" ]],
222+ hasNext : true
223+ ]
224+
225+ when :
226+ def incrementalResults = getIncrementalResults(initialResult)
227+
228+ then :
229+ incrementalResults == [
230+ [
231+ hasNext : false ,
232+ incremental : [
233+ [
234+ path : [" postAlias" ],
235+ data : [summaryAlias : " A summary" ]
236+ ]
237+ ]
238+ ]
239+ ]
240+ }
241+
204242 def " defer on interface field" () {
205243 def query = """
206244 query {
You can’t perform that action at this time.
0 commit comments