@@ -8,21 +8,17 @@ import { resolveOnNextTick } from '../../__testUtils__/resolveOnNextTick.ts';
88
99import { inspect } from '../../jsutils/inspect.ts' ;
1010import type { PromiseOrValue } from '../../jsutils/PromiseOrValue.ts' ;
11- import { promiseWithResolvers } from '../../jsutils/promiseWithResolvers.ts' ;
1211
1312import type { FieldNode } from '../../language/ast.ts' ;
14- import { Kind } from '../../language/kinds.ts' ;
1513import { parse } from '../../language/parser.ts' ;
1614
17- import type { GraphQLResolveInfo } from '../../type/definition.ts' ;
1815import {
1916 GraphQLInputObjectType ,
2017 GraphQLInterfaceType ,
2118 GraphQLList ,
2219 GraphQLNonNull ,
2320 GraphQLObjectType ,
2421 GraphQLScalarType ,
25- GraphQLUnionType ,
2622} from '../../type/definition.ts' ;
2723import { GraphQLStreamDirective } from '../../type/directives.ts' ;
2824import {
@@ -223,161 +219,6 @@ describe('Execute: Handles basic execution tasks', () => {
223219 } ) ;
224220 } ) ;
225221
226- it ( 'provides info about current execution state' , async ( ) => {
227- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
228- const { promise, resolve } = promiseWithResolvers < void > ( ) ;
229- let resolvedInfo : GraphQLResolveInfo | undefined ;
230- const testType = new GraphQLObjectType ( {
231- name : 'Test' ,
232- fields : {
233- test : {
234- type : GraphQLString ,
235- resolve ( _val , _args , _ctx , info ) {
236- resolvedInfo = info ;
237- return promise ;
238- } ,
239- } ,
240- } ,
241- } ) ;
242- const schema = new GraphQLSchema ( { query : testType } ) ;
243-
244- const document = parse ( 'query ($var: String) { result: test }' ) ;
245- const rootValue = { root : 'val' } ;
246- const variableValues = { var : 'abc' } ;
247-
248- const result = execute ( { schema, document, rootValue, variableValues } ) ;
249-
250- expect ( resolvedInfo ) . to . have . all . keys (
251- 'fieldName' ,
252- 'fieldNodes' ,
253- 'returnType' ,
254- 'parentType' ,
255- 'path' ,
256- 'schema' ,
257- 'fragments' ,
258- 'rootValue' ,
259- 'operation' ,
260- 'variableValues' ,
261- 'getAbortSignal' ,
262- 'getAsyncHelpers' ,
263- ) ;
264- const asyncHelpers = resolvedInfo ?. getAsyncHelpers ( ) ;
265- expect ( asyncHelpers ) . to . have . all . keys ( 'promiseAll' , 'track' ) ;
266-
267- const operation = document . definitions [ 0 ] ;
268- assert ( operation . kind === Kind . OPERATION_DEFINITION ) ;
269-
270- expect ( resolvedInfo ) . to . include ( {
271- fieldName : 'test' ,
272- returnType : GraphQLString ,
273- parentType : testType ,
274- schema,
275- rootValue,
276- operation,
277- } ) ;
278-
279- const field = operation . selectionSet . selections [ 0 ] ;
280- expect ( resolvedInfo ) . to . deep . include ( {
281- fieldNodes : [ field ] ,
282- path : { prev : undefined , key : 'result' , typename : 'Test' } ,
283- variableValues : {
284- sources : {
285- var : {
286- signature : {
287- name : 'var' ,
288- type : GraphQLString ,
289- default : undefined ,
290- } ,
291- value : 'abc' ,
292- } ,
293- } ,
294- coerced : { var : 'abc' } ,
295- } ,
296- } ) ;
297-
298- const abortSignal = resolvedInfo ?. getAbortSignal ( ) ;
299- expect ( abortSignal ) . to . be . instanceOf ( AbortSignal ) ;
300- expect ( resolvedInfo ?. getAbortSignal ( ) ) . to . equal ( abortSignal ) ;
301-
302- expect ( resolvedInfo ?. getAsyncHelpers ( ) ) . to . equal ( asyncHelpers ) ;
303-
304- const promiseAll = asyncHelpers ?. promiseAll ;
305- expect ( promiseAll ) . to . be . a ( 'function' ) ;
306- expect ( resolvedInfo ?. getAsyncHelpers ( ) . promiseAll ) . to . equal ( promiseAll ) ;
307-
308- const track = asyncHelpers ?. track ;
309- expect ( track ) . to . be . a ( 'function' ) ;
310- expect ( resolvedInfo ?. getAsyncHelpers ( ) . track ) . to . equal ( track ) ;
311- track ?.( [ Promise . resolve ( ) ] ) ;
312-
313- resolve ( ) ;
314-
315- await result ;
316-
317- const lateAbortSignal = resolvedInfo ?. getAbortSignal ( ) ;
318- expect ( lateAbortSignal ) . to . be . instanceOf ( AbortSignal ) ;
319- expect ( lateAbortSignal ?. aborted ) . to . equal ( true ) ;
320- } ) ;
321-
322- it ( 'populates path correctly with complex types' , ( ) => {
323- let path ;
324- const someObject = new GraphQLObjectType ( {
325- name : 'SomeObject' ,
326- fields : {
327- test : {
328- type : GraphQLString ,
329- resolve ( _val , _args , _ctx , info ) {
330- path = info . path ;
331- } ,
332- } ,
333- } ,
334- } ) ;
335- const someUnion = new GraphQLUnionType ( {
336- name : 'SomeUnion' ,
337- types : [ someObject ] ,
338- resolveType ( ) {
339- return 'SomeObject' ;
340- } ,
341- } ) ;
342- const testType = new GraphQLObjectType ( {
343- name : 'SomeQuery' ,
344- fields : {
345- test : {
346- type : new GraphQLNonNull (
347- new GraphQLList ( new GraphQLNonNull ( someUnion ) ) ,
348- ) ,
349- } ,
350- } ,
351- } ) ;
352- const schema = new GraphQLSchema ( { query : testType } ) ;
353- const rootValue = { test : [ { } ] } ;
354- const document = parse ( `
355- query {
356- l1: test {
357- ... on SomeObject {
358- l2: test
359- }
360- }
361- }
362- ` ) ;
363-
364- executeSync ( { schema, document, rootValue } ) ;
365-
366- expect ( path ) . to . deep . equal ( {
367- key : 'l2' ,
368- typename : 'SomeObject' ,
369- prev : {
370- key : 0 ,
371- typename : undefined ,
372- prev : {
373- key : 'l1' ,
374- typename : 'SomeQuery' ,
375- prev : undefined ,
376- } ,
377- } ,
378- } ) ;
379- } ) ;
380-
381222 it ( 'threads root value context correctly' , ( ) => {
382223 let resolvedRootValue ;
383224 const schema = new GraphQLSchema ( {
0 commit comments