@@ -368,11 +368,11 @@ export class GraphQLObjectType {
368
368
description : ?string ;
369
369
isTypeOf : ?GraphQLIsTypeOfFn ;
370
370
371
- _typeConfig : GraphQLObjectTypeConfig < * > ;
372
- _fields : GraphQLFieldMap ;
371
+ _typeConfig : GraphQLObjectTypeConfig < * , * > ;
372
+ _fields : GraphQLFieldMap < * , * > ;
373
373
_interfaces : Array < GraphQLInterfaceType > ;
374
374
375
- constructor ( config : GraphQLObjectTypeConfig < * > ) {
375
+ constructor ( config : GraphQLObjectTypeConfig < * , * > ) {
376
376
invariant ( config . name , 'Type must be named.' ) ;
377
377
assertValidName ( config . name ) ;
378
378
this . name = config . name ;
@@ -387,7 +387,7 @@ export class GraphQLObjectType {
387
387
this . _typeConfig = config ;
388
388
}
389
389
390
- getFields ( ) : GraphQLFieldMap {
390
+ getFields ( ) : GraphQLFieldMap < * , * > {
391
391
return this . _fields || ( this . _fields =
392
392
defineFieldMap ( this , this . _typeConfig . fields )
393
393
) ;
@@ -436,10 +436,10 @@ function defineInterfaces(
436
436
return interfaces ;
437
437
}
438
438
439
- function defineFieldMap (
439
+ function defineFieldMap < TSource , TContext > (
440
440
type : GraphQLNamedType ,
441
- fieldsThunk : Thunk < GraphQLFieldConfigMap < * >>
442
- ) : GraphQLFieldMap {
441
+ fieldsThunk : Thunk < GraphQLFieldConfigMap < TSource , TContext >>
442
+ ) : GraphQLFieldMap < TSource , TContext > {
443
443
const fieldMap = resolveThunk ( fieldsThunk ) ;
444
444
invariant (
445
445
isPlainObj ( fieldMap ) ,
@@ -507,10 +507,10 @@ function isPlainObj(obj) {
507
507
return obj && typeof obj === 'object ' && ! Array . isArray ( obj ) ;
508
508
}
509
509
510
- export type GraphQLObjectTypeConfig < TSource > = {
510
+ export type GraphQLObjectTypeConfig < TSource , TContext > = {
511
511
name : string ;
512
512
interfaces ?: Thunk < ?Array < GraphQLInterfaceType >> ;
513
- fields : Thunk < GraphQLFieldConfigMap < TSource >> ;
513
+ fields : Thunk < GraphQLFieldConfigMap < TSource , TContext >> ;
514
514
isTypeOf ?: ?GraphQLIsTypeOfFn ;
515
515
description ?: ?string
516
516
} ;
@@ -527,10 +527,10 @@ export type GraphQLIsTypeOfFn = (
527
527
info : GraphQLResolveInfo
528
528
) => boolean ;
529
529
530
- export type GraphQLFieldResolver < TSource > = (
530
+ export type GraphQLFieldResolver < TSource , TContext > = (
531
531
source : TSource ,
532
532
args : { [ argName : string ] : mixed } ,
533
- context : mixed ,
533
+ context : TContext ,
534
534
info : GraphQLResolveInfo
535
535
) => mixed ;
536
536
@@ -549,10 +549,10 @@ export type GraphQLResolveInfo = {
549
549
550
550
export type ResponsePath = { prev : ResponsePath , key : string | number } | void ;
551
551
552
- export type GraphQLFieldConfig < TSource > = {
552
+ export type GraphQLFieldConfig < TSource , TContext > = {
553
553
type : GraphQLOutputType ;
554
554
args ?: GraphQLFieldConfigArgumentMap ;
555
- resolve ?: GraphQLFieldResolver < TSource > ;
555
+ resolve ?: GraphQLFieldResolver < TSource , TContext > ;
556
556
deprecationReason ?: ?string ;
557
557
description ?: ?string ;
558
558
} ;
@@ -567,16 +567,16 @@ export type GraphQLArgumentConfig = {
567
567
description ?: ?string ;
568
568
} ;
569
569
570
- export type GraphQLFieldConfigMap < TSource > = {
571
- [ fieldName : string ] : GraphQLFieldConfig < TSource > ;
570
+ export type GraphQLFieldConfigMap < TSource , TContext > = {
571
+ [ fieldName : string ] : GraphQLFieldConfig < TSource , TContext > ;
572
572
} ;
573
573
574
- export type GraphQLField = {
574
+ export type GraphQLField < TSource , TContext > = {
575
575
name : string ;
576
576
description : ?string ;
577
577
type : GraphQLOutputType ;
578
578
args : Array < GraphQLArgument > ;
579
- resolve ?: GraphQLFieldResolver < * > ;
579
+ resolve ?: GraphQLFieldResolver < TSource , TContext > ;
580
580
isDeprecated ?: boolean ;
581
581
deprecationReason ?: ?string ;
582
582
} ;
@@ -588,8 +588,8 @@ export type GraphQLArgument = {
588
588
description ?: ?string ;
589
589
} ;
590
590
591
- export type GraphQLFieldMap = {
592
- [ fieldName : string ] : GraphQLField ;
591
+ export type GraphQLFieldMap < TSource , TContext > = {
592
+ [ fieldName : string ] : GraphQLField < TSource , TContext > ;
593
593
} ;
594
594
595
595
@@ -617,10 +617,10 @@ export class GraphQLInterfaceType {
617
617
description : ?string ;
618
618
resolveType : ?GraphQLTypeResolver ;
619
619
620
- _typeConfig : GraphQLInterfaceTypeConfig ;
621
- _fields : GraphQLFieldMap ;
620
+ _typeConfig : GraphQLInterfaceTypeConfig < * , * > ;
621
+ _fields : GraphQLFieldMap < * , * > ;
622
622
623
- constructor ( config : GraphQLInterfaceTypeConfig ) {
623
+ constructor ( config : GraphQLInterfaceTypeConfig < * , * > ) {
624
624
invariant ( config . name , 'Type must be named.' ) ;
625
625
assertValidName ( config . name ) ;
626
626
this . name = config . name ;
@@ -635,7 +635,7 @@ export class GraphQLInterfaceType {
635
635
this . _typeConfig = config ;
636
636
}
637
637
638
- getFields ( ) : GraphQLFieldMap {
638
+ getFields ( ) : GraphQLFieldMap < * , * > {
639
639
return this . _fields ||
640
640
( this . _fields = defineFieldMap ( this , this . _typeConfig . fields ) ) ;
641
641
}
@@ -645,9 +645,9 @@ export class GraphQLInterfaceType {
645
645
}
646
646
}
647
647
648
- export type GraphQLInterfaceTypeConfig = {
648
+ export type GraphQLInterfaceTypeConfig < TSource , TContext > = {
649
649
name : string ,
650
- fields : Thunk < GraphQLFieldConfigMap < mixed >> ,
650
+ fields : Thunk < GraphQLFieldConfigMap < TSource , TContext > > ,
651
651
/**
652
652
* Optionally provide a custom type resolver function. If one is not provided,
653
653
* the default implementation will call `isTypeOf` on each implementing
0 commit comments