@@ -41,6 +41,7 @@ import type {
4141 FieldNode ,
4242 FragmentDefinitionNode ,
4343 ValueNode ,
44+ ConstValueNode ,
4445} from '../language/ast' ;
4546
4647import { valueFromASTUntyped } from '../utilities/valueFromASTUntyped' ;
@@ -971,11 +972,18 @@ export function defineInputValue(
971972 ! ( 'resolve' in config ) ,
972973 `${ name } has a resolve property, but inputs cannot define resolvers.` ,
973974 ) ;
975+ let defaultValue ;
976+ if ( config . defaultValue !== undefined || config . defaultValueLiteral ) {
977+ defaultValue = {
978+ value : config . defaultValue ,
979+ literal : config . defaultValueLiteral ,
980+ } ;
981+ }
974982 return {
975983 name,
976984 description : config . description ,
977985 type : config . type ,
978- defaultValue : config . defaultValue ,
986+ defaultValue,
979987 deprecationReason : config . deprecationReason ,
980988 extensions : config . extensions && toObjMap ( config . extensions ) ,
981989 astNode : config . astNode ,
@@ -991,7 +999,8 @@ export function inputValueToConfig(
991999 return {
9921000 description : inputValue . description ,
9931001 type : inputValue . type ,
994- defaultValue : inputValue . defaultValue ,
1002+ defaultValue : inputValue . defaultValue ?. value ,
1003+ defaultValueLiteral : inputValue . defaultValue ?. literal ,
9951004 deprecationReason : inputValue . deprecationReason ,
9961005 extensions : inputValue . extensions ,
9971006 astNode : inputValue . astNode ,
@@ -1002,16 +1011,22 @@ export type GraphQLInputValue = {|
10021011 name : string ,
10031012 description : ?string ,
10041013 type : GraphQLInputType ,
1005- defaultValue : mixed ,
1014+ defaultValue : ? GraphQLDefaultValueUsage ,
10061015 deprecationReason : ?string ,
10071016 extensions : ?ReadOnlyObjMap < mixed > ,
10081017 astNode : ?InputValueDefinitionNode ,
10091018| } ;
10101019
1020+ export type GraphQLDefaultValueUsage = { |
1021+ value : mixed ,
1022+ literal : ?ConstValueNode ,
1023+ | } ;
1024+
10111025export type GraphQLInputValueConfig = { |
10121026 description ?: ?string ,
10131027 type : GraphQLInputType ,
10141028 defaultValue ?: mixed ,
1029+ defaultValueLiteral ?: ?ConstValueNode ,
10151030 deprecationReason ?: ?string ,
10161031 extensions ?: ?ReadOnlyObjMapLike < mixed > ,
10171032 astNode ?: ?InputValueDefinitionNode ,
0 commit comments