@@ -584,8 +584,8 @@ export class GraphQLScalarType<TInternal = unknown, TExternal = TInternal> {
584
584
name : string ;
585
585
description : Maybe < string > ;
586
586
specifiedByURL : Maybe < string > ;
587
- serialize : GraphQLScalarSerializer < TExternal > ;
588
- parseValue : GraphQLScalarValueParser < TInternal > ;
587
+ serialize : GraphQLScalarSerializer < TExternal , TInternal > ;
588
+ parseValue : GraphQLScalarValueParser < TInternal , TExternal > ;
589
589
parseLiteral : GraphQLScalarLiteralParser < TInternal > ;
590
590
extensions : Readonly < GraphQLScalarTypeExtensions > ;
591
591
astNode : Maybe < ScalarTypeDefinitionNode > ;
@@ -594,17 +594,19 @@ export class GraphQLScalarType<TInternal = unknown, TExternal = TInternal> {
594
594
constructor ( config : Readonly < GraphQLScalarTypeConfig < TInternal , TExternal > > ) {
595
595
const parseValue =
596
596
config . parseValue ??
597
- ( identityFunc as GraphQLScalarValueParser < TInternal > ) ;
597
+ ( identityFunc as GraphQLScalarValueParser < TInternal , TExternal > ) ;
598
598
599
599
this . name = assertName ( config . name ) ;
600
600
this . description = config . description ;
601
601
this . specifiedByURL = config . specifiedByURL ;
602
602
this . serialize =
603
- config . serialize ?? ( identityFunc as GraphQLScalarSerializer < TExternal > ) ;
603
+ config . serialize ??
604
+ ( identityFunc as GraphQLScalarSerializer < TExternal , TInternal > ) ;
604
605
this . parseValue = parseValue ;
605
606
this . parseLiteral =
606
607
config . parseLiteral ??
607
- ( ( node , variables ) => parseValue ( valueFromASTUntyped ( node , variables ) ) ) ;
608
+ ( ( node , variables ) =>
609
+ parseValue ( valueFromASTUntyped ( node , variables ) as TExternal ) ) ;
608
610
this . extensions = toObjMap ( config . extensions ) ;
609
611
this . astNode = config . astNode ;
610
612
this . extensionASTNodes = config . extensionASTNodes ?? [ ] ;
@@ -657,12 +659,12 @@ export class GraphQLScalarType<TInternal = unknown, TExternal = TInternal> {
657
659
}
658
660
}
659
661
660
- export type GraphQLScalarSerializer < TExternal > = (
661
- outputValue : unknown ,
662
+ export type GraphQLScalarSerializer < TExternal , TInternal > = (
663
+ outputValue : TInternal ,
662
664
) => TExternal ;
663
665
664
- export type GraphQLScalarValueParser < TInternal > = (
665
- inputValue : unknown ,
666
+ export type GraphQLScalarValueParser < TInternal , TExternal > = (
667
+ inputValue : TExternal ,
666
668
) => TInternal ;
667
669
668
670
export type GraphQLScalarLiteralParser < TInternal > = (
@@ -675,9 +677,9 @@ export interface GraphQLScalarTypeConfig<TInternal, TExternal> {
675
677
description ?: Maybe < string > ;
676
678
specifiedByURL ?: Maybe < string > ;
677
679
/** Serializes an internal value to include in a response. */
678
- serialize ?: GraphQLScalarSerializer < TExternal > ;
680
+ serialize ?: GraphQLScalarSerializer < TExternal , TInternal > ;
679
681
/** Parses an externally provided value to use as an input. */
680
- parseValue ?: GraphQLScalarValueParser < TInternal > ;
682
+ parseValue ?: GraphQLScalarValueParser < TInternal , TExternal > ;
681
683
/** Parses an externally provided literal value to use as an input. */
682
684
parseLiteral ?: GraphQLScalarLiteralParser < TInternal > ;
683
685
extensions ?: Maybe < Readonly < GraphQLScalarTypeExtensions > > ;
@@ -687,8 +689,8 @@ export interface GraphQLScalarTypeConfig<TInternal, TExternal> {
687
689
688
690
interface GraphQLScalarTypeNormalizedConfig < TInternal , TExternal >
689
691
extends GraphQLScalarTypeConfig < TInternal , TExternal > {
690
- serialize : GraphQLScalarSerializer < TExternal > ;
691
- parseValue : GraphQLScalarValueParser < TInternal > ;
692
+ serialize : GraphQLScalarSerializer < TExternal , TInternal > ;
693
+ parseValue : GraphQLScalarValueParser < TInternal , TExternal > ;
692
694
parseLiteral : GraphQLScalarLiteralParser < TInternal > ;
693
695
extensions : Readonly < GraphQLScalarTypeExtensions > ;
694
696
extensionASTNodes : ReadonlyArray < ScalarTypeExtensionNode > ;
0 commit comments