@@ -19,6 +19,10 @@ import { buildSchema } from '../../utilities/buildASTSchema.js';
19
19
20
20
import { execute , executeSync } from '../execute.js' ;
21
21
22
+ interface Context {
23
+ async : boolean ;
24
+ }
25
+
22
26
async function executeQuery ( args : {
23
27
schema : GraphQLSchema ;
24
28
query : string ;
@@ -30,13 +34,13 @@ async function executeQuery(args: {
30
34
schema,
31
35
document,
32
36
rootValue,
33
- contextValue : { async : false } ,
37
+ contextValue : { async : false } satisfies Context ,
34
38
} ) ;
35
39
const asyncResult = await execute ( {
36
40
schema,
37
41
document,
38
42
rootValue,
39
- contextValue : { async : true } ,
43
+ contextValue : { async : true } satisfies Context ,
40
44
} ) ;
41
45
42
46
expectJSON ( result ) . toDeepEqual ( asyncResult ) ;
@@ -72,7 +76,7 @@ describe('Execute: Handles execution of abstract types', () => {
72
76
} ,
73
77
} ) ;
74
78
75
- const DogType = new GraphQLObjectType ( {
79
+ const DogType = new GraphQLObjectType < Dog , { async : boolean } > ( {
76
80
name : 'Dog' ,
77
81
interfaces : [ PetType ] ,
78
82
isTypeOf ( obj , context ) {
@@ -85,7 +89,7 @@ describe('Execute: Handles execution of abstract types', () => {
85
89
} ,
86
90
} ) ;
87
91
88
- const CatType = new GraphQLObjectType ( {
92
+ const CatType = new GraphQLObjectType < Cat , { async : boolean } > ( {
89
93
name : 'Cat' ,
90
94
interfaces : [ PetType ] ,
91
95
isTypeOf ( obj , context ) {
@@ -151,7 +155,7 @@ describe('Execute: Handles execution of abstract types', () => {
151
155
} ,
152
156
} ) ;
153
157
154
- const DogType = new GraphQLObjectType ( {
158
+ const DogType = new GraphQLObjectType < Dog , Context > ( {
155
159
name : 'Dog' ,
156
160
interfaces : [ PetType ] ,
157
161
isTypeOf ( _source , context ) {
@@ -167,7 +171,7 @@ describe('Execute: Handles execution of abstract types', () => {
167
171
} ,
168
172
} ) ;
169
173
170
- const CatType = new GraphQLObjectType ( {
174
+ const CatType = new GraphQLObjectType < Cat , Context > ( {
171
175
name : 'Cat' ,
172
176
interfaces : [ PetType ] ,
173
177
isTypeOf : undefined ,
@@ -233,7 +237,7 @@ describe('Execute: Handles execution of abstract types', () => {
233
237
} ,
234
238
} ) ;
235
239
236
- const DogType = new GraphQLObjectType ( {
240
+ const DogType = new GraphQLObjectType < Dog , Context > ( {
237
241
name : 'Dog' ,
238
242
interfaces : [ PetType ] ,
239
243
isTypeOf ( _source , context ) {
@@ -280,7 +284,7 @@ describe('Execute: Handles execution of abstract types', () => {
280
284
} ) ;
281
285
282
286
it ( 'isTypeOf used to resolve runtime type for Union' , async ( ) => {
283
- const DogType = new GraphQLObjectType ( {
287
+ const DogType = new GraphQLObjectType < Dog , Context > ( {
284
288
name : 'Dog' ,
285
289
isTypeOf ( obj , context ) {
286
290
const isDog = obj instanceof Dog ;
@@ -292,7 +296,7 @@ describe('Execute: Handles execution of abstract types', () => {
292
296
} ,
293
297
} ) ;
294
298
295
- const CatType = new GraphQLObjectType ( {
299
+ const CatType = new GraphQLObjectType < Cat , Context > ( {
296
300
name : 'Cat' ,
297
301
isTypeOf ( obj , context ) {
298
302
const isCat = obj instanceof Cat ;
@@ -357,7 +361,7 @@ describe('Execute: Handles execution of abstract types', () => {
357
361
name : 'Pet' ,
358
362
resolveType ( _source , context ) {
359
363
const error = new Error ( 'We are testing this error' ) ;
360
- if ( context . async ) {
364
+ if ( context . async === true ) {
361
365
return Promise . reject ( error ) ;
362
366
}
363
367
throw error ;
@@ -367,7 +371,7 @@ describe('Execute: Handles execution of abstract types', () => {
367
371
} ,
368
372
} ) ;
369
373
370
- const DogType = new GraphQLObjectType ( {
374
+ const DogType = new GraphQLObjectType < Dog , Context > ( {
371
375
name : 'Dog' ,
372
376
interfaces : [ PetType ] ,
373
377
fields : {
@@ -376,7 +380,7 @@ describe('Execute: Handles execution of abstract types', () => {
376
380
} ,
377
381
} ) ;
378
382
379
- const CatType = new GraphQLObjectType ( {
383
+ const CatType = new GraphQLObjectType < Cat , Context > ( {
380
384
name : 'Cat' ,
381
385
interfaces : [ PetType ] ,
382
386
fields : {
0 commit comments