@@ -552,6 +552,7 @@ export class GraphQLScalarType {
552
552
extensions : ?ReadOnlyObjMap < mixed > ;
553
553
astNode : ?ScalarTypeDefinitionNode ;
554
554
extensionASTNodes : ?$ReadOnlyArray < ScalarTypeExtensionNode > ;
555
+ specifiedBy : ?string ;
555
556
556
557
constructor ( config : GraphQLScalarTypeConfig < * , * > ) : void {
557
558
const parseValue = config . parseValue || identityFunc ;
@@ -564,6 +565,7 @@ export class GraphQLScalarType {
564
565
this . extensions = config . extensions && toObjMap ( config . extensions ) ;
565
566
this . astNode = config . astNode ;
566
567
this . extensionASTNodes = undefineIfEmpty ( config . extensionASTNodes ) ;
568
+ this . specifiedBy = config . specifiedBy ;
567
569
568
570
devAssert ( typeof config . name === 'string' , 'Must provide name.' ) ;
569
571
devAssert (
@@ -578,6 +580,14 @@ export class GraphQLScalarType {
578
580
`${ this . name } must provide both "parseValue" and "parseLiteral" functions.` ,
579
581
) ;
580
582
}
583
+
584
+ if ( config . specifiedBy !== undefined ) {
585
+ devAssert (
586
+ typeof config . specifiedBy === 'string' ,
587
+ `${ this . name } must provide "specifiedBy" as a string, ` +
588
+ `but got: ${ inspect ( config . specifiedBy ) } .` ,
589
+ ) ;
590
+ }
581
591
}
582
592
583
593
toConfig ( ) : { |
@@ -587,6 +597,7 @@ export class GraphQLScalarType {
587
597
parseLiteral : GraphQLScalarLiteralParser < * > ,
588
598
extensions : ?ReadOnlyObjMap < mixed > ,
589
599
extensionASTNodes : ?$ReadOnlyArray < ScalarTypeExtensionNode > ,
600
+ specifiedBy : ?string ,
590
601
| } {
591
602
return {
592
603
name : this . name ,
@@ -597,6 +608,7 @@ export class GraphQLScalarType {
597
608
extensions : this . extensions ,
598
609
astNode : this . astNode ,
599
610
extensionASTNodes : this . extensionASTNodes ,
611
+ specifiedBy : this . specifiedBy ,
600
612
} ;
601
613
}
602
614
@@ -628,6 +640,7 @@ export type GraphQLScalarTypeConfig<TInternal, TExternal> = {|
628
640
extensions ?: ?ReadOnlyObjMapLike < mixed > ,
629
641
astNode ?: ?ScalarTypeDefinitionNode ,
630
642
extensionASTNodes ?: ?$ReadOnlyArray < ScalarTypeExtensionNode > ,
643
+ specifiedBy ?: ?string ,
631
644
| } ;
632
645
633
646
/**
0 commit comments