@@ -106,8 +106,8 @@ describe('Star Wars Query Deferred Tests', () => {
106106 ` ;
107107
108108 const result = await graphql ( StarWarsSchemaDeferStreamEnabled , query ) ;
109- const { patches : patchesIterable , ...rest } = result ;
110- expect ( rest ) . to . deep . equal ( {
109+ const { patches : patchesIterable , ...initial } = result ;
110+ expect ( initial ) . to . deep . equal ( {
111111 data : {
112112 hero : {
113113 id : '2001' ,
@@ -149,6 +149,49 @@ describe('Star Wars Query Deferred Tests', () => {
149149 // TODO
150150 // describe('Using aliases to change the key in the response', () => {});
151151
152+ describe ( 'Inline Fragments' , ( ) => {
153+ it ( 'Allows us to defer an inline fragment' , async ( ) => {
154+ const query = `
155+ query UserFragment {
156+ human(id: "1003") {
157+ id
158+ ... on Human @defer(label: "InlineDeferred"){
159+ name
160+ homePlanet
161+ }
162+ }
163+ }
164+
165+ ` ;
166+ const result = await graphql ( StarWarsSchemaDeferStreamEnabled , query ) ;
167+ const { patches : patchesIterable , ...initial } = result ;
168+ expect ( initial ) . to . deep . equal ( {
169+ data : {
170+ human : {
171+ id : '1003' ,
172+ } ,
173+ } ,
174+ } ) ;
175+
176+ const patches = [ ] ;
177+
178+ if ( patchesIterable ) {
179+ await forAwaitEach ( patchesIterable , patch => {
180+ patches . push ( patch ) ;
181+ } ) ;
182+ }
183+ expect ( patches ) . to . have . lengthOf ( 1 ) ;
184+ expect ( patches [ 0 ] ) . to . deep . equal ( {
185+ label : 'InlineDeferred' ,
186+ path : [ 'human' ] ,
187+ data : {
188+ name : 'Leia Organa' ,
189+ homePlanet : 'Alderaan' ,
190+ } ,
191+ } ) ;
192+ } ) ;
193+ } ) ;
194+
152195 describe ( 'Uses fragments to express more complex queries' , ( ) => {
153196 it ( 'Allows us to use a fragment to avoid duplicating content' , async ( ) => {
154197 const query = `
@@ -183,9 +226,9 @@ describe('Star Wars Query Deferred Tests', () => {
183226 }
184227 ` ;
185228 const result = await graphql ( StarWarsSchemaDeferStreamEnabled , query ) ;
186- const { patches : patchesIterable , ...rest } = result ;
229+ const { patches : patchesIterable , ...initial } = result ;
187230
188- expect ( rest ) . to . deep . equal ( {
231+ expect ( initial ) . to . deep . equal ( {
189232 data : {
190233 han : {
191234 __typename : 'Human' ,
0 commit comments