@@ -183,6 +183,55 @@ describe('Execute: Handles basic execution tasks', () => {
183
183
} ) ;
184
184
} ) ;
185
185
186
+ it ( 'provides info about current execution state' , async ( ) => {
187
+ const ast = parse ( 'query ($var: String) { result: test }' ) ;
188
+
189
+ let info ;
190
+
191
+ const schema = new GraphQLSchema ( {
192
+ query : new GraphQLObjectType ( {
193
+ name : 'Test' ,
194
+ fields : {
195
+ test : {
196
+ type : GraphQLString ,
197
+ resolve ( val , args , ctx , _info ) {
198
+ info = _info ;
199
+ }
200
+ }
201
+ }
202
+ } )
203
+ } ) ;
204
+
205
+ const rootValue = { root : 'val' } ;
206
+
207
+ await execute ( schema , ast , rootValue , null , { var : 123 } ) ;
208
+
209
+ expect ( Object . keys ( info ) ) . to . deep . equal ( [
210
+ 'fieldName' ,
211
+ 'fieldASTs' ,
212
+ 'returnType' ,
213
+ 'parentType' ,
214
+ 'path' ,
215
+ 'schema' ,
216
+ 'fragments' ,
217
+ 'rootValue' ,
218
+ 'operation' ,
219
+ 'variableValues' ,
220
+ ] ) ;
221
+ expect ( info . fieldName ) . to . equal ( 'test' ) ;
222
+ expect ( info . fieldASTs ) . to . have . lengthOf ( 1 ) ;
223
+ expect ( info . fieldASTs [ 0 ] ) . to . equal (
224
+ ast . definitions [ 0 ] . selectionSet . selections [ 0 ]
225
+ ) ;
226
+ expect ( info . returnType ) . to . equal ( GraphQLString ) ;
227
+ expect ( info . parentType ) . to . equal ( schema . getQueryType ( ) ) ;
228
+ expect ( info . path ) . to . deep . equal ( [ 'result' ] ) ;
229
+ expect ( info . schema ) . to . equal ( schema ) ;
230
+ expect ( info . rootValue ) . to . equal ( rootValue ) ;
231
+ expect ( info . operation ) . to . equal ( ast . definitions [ 0 ] ) ;
232
+ expect ( info . variableValues ) . to . deep . equal ( { var : '123' } ) ;
233
+ } ) ;
234
+
186
235
it ( 'threads root value context correctly' , async ( ) => {
187
236
const doc = 'query Example { a }' ;
188
237
0 commit comments