1- import  type  {  ObjMap  }  from  '../jsutils/ObjMap' ; 
2- import  {  keyMap  }  from  '../jsutils/keyMap' ; 
1+ import  type  {  ReadOnlyObjMap ,  ReadOnlyObjMapLike  }  from  '../jsutils/ObjMap' ; 
32import  {  inspect  }  from  '../jsutils/inspect' ; 
3+ import  {  keyMap  }  from  '../jsutils/keyMap' ; 
44import  {  printPathArray  }  from  '../jsutils/printPathArray' ; 
55
66import  {  GraphQLError  }  from  '../error/GraphQLError' ; 
@@ -14,7 +14,7 @@ import { Kind } from '../language/kinds';
1414import  {  print  }  from  '../language/printer' ; 
1515
1616import  type  {  GraphQLSchema  }  from  '../type/schema' ; 
17- import  type  {  GraphQLField  }  from  '../type/definition' ; 
17+ import  type  {  GraphQLInputType ,   GraphQLField  }  from  '../type/definition' ; 
1818import  type  {  GraphQLDirective  }  from  '../type/directives' ; 
1919import  {  isInputType ,  isNonNullType  }  from  '../type/definition' ; 
2020import  {  getCoercedDefaultValue  }  from  '../type/defaultValues' ; 
@@ -23,9 +23,18 @@ import { typeFromAST } from '../utilities/typeFromAST';
2323import  {  valueFromAST  }  from  '../utilities/valueFromAST' ; 
2424import  {  coerceInputValue  }  from  '../utilities/coerceInputValue' ; 
2525
26+ export  type  VariableValues  =  { | 
27+   + sources : ReadOnlyObjMap < { | 
28+     + variable : VariableDefinitionNode , 
29+     + type : GraphQLInputType , 
30+     + value : mixed , 
31+   | } > , 
32+   + coerced : ReadOnlyObjMap < mixed > , 
33+ | } ; 
34+ 
2635type   CoercedVariableValues  = 
2736  |  { |  errors : $ReadOnlyArray < GraphQLError >  | } 
28-   |  { |  coerced : {   [ variable :  string ] :  mixed ,  ...  }  | } ; 
37+   |  { |  coerced : VariableValues  | } ; 
2938
3039/** 
3140 * Prepares an object map of variableValues of the correct type based on the 
@@ -41,7 +50,7 @@ type CoercedVariableValues =
4150export  function  getVariableValues ( 
4251  schema : GraphQLSchema , 
4352  varDefNodes : $ReadOnlyArray < VariableDefinitionNode > , 
44-   inputs : {   + [ variable :  string ] :  mixed ,  ...  } , 
53+   inputs : ReadOnlyObjMapLike < mixed > , 
4554  options ?: { |  maxErrors ?: number  | } , 
4655) : CoercedVariableValues  { 
4756  const  errors =  [ ] ; 
@@ -74,10 +83,11 @@ export function getVariableValues(
7483function  coerceVariableValues ( 
7584  schema : GraphQLSchema , 
7685  varDefNodes : $ReadOnlyArray < VariableDefinitionNode > , 
77-   inputs : {   + [ variable :  string ] :  mixed ,  ...  } , 
86+   inputs : ReadOnlyObjMapLike < mixed > , 
7887  onError : ( error : GraphQLError )  = >  void , 
79- ) : {  [ variable : string ] : mixed ,  ... }  { 
80-   const  coercedValues =  { } ; 
88+ ) : VariableValues  { 
89+   const  sources  =  Object . create ( null ) ; 
90+   const  coerced  =  Object . create ( null ) ; 
8191  for  ( const  varDefNode  of  varDefNodes )  { 
8292    const  varName  =  varDefNode . variable . name . value ; 
8393    const  varType  =  typeFromAST ( schema ,  varDefNode . type ) ; 
@@ -96,7 +106,12 @@ function coerceVariableValues(
96106
97107    if  ( ! hasOwnProperty ( inputs ,  varName ) )  { 
98108      if  ( varDefNode . defaultValue )  { 
99-         coercedValues [ varName ]  =  valueFromAST ( varDefNode . defaultValue ,  varType ) ; 
109+         sources [ varName ]  =  { 
110+           variable : varDefNode , 
111+           type : varType , 
112+           value : undefined , 
113+         } ; 
114+         coerced [ varName ]  =  valueFromAST ( varDefNode . defaultValue ,  varType ) ; 
100115      }  else  if  ( isNonNullType ( varType ) )  { 
101116        const  varTypeStr  =  inspect ( varType ) ; 
102117        onError ( 
@@ -121,7 +136,8 @@ function coerceVariableValues(
121136      continue ; 
122137    } 
123138
124-     coercedValues [ varName ]  =  coerceInputValue ( 
139+     sources [ varName ]  =  {  variable : varDefNode ,  type : varType ,  value } ; 
140+     coerced [ varName ]  =  coerceInputValue ( 
125141      value , 
126142      varType , 
127143      ( path ,  invalidValue ,  error )  =>  { 
@@ -144,7 +160,7 @@ function coerceVariableValues(
144160    ) ; 
145161  } 
146162
147-   return  coercedValues ; 
163+   return  {  sources ,  coerced  } ; 
148164} 
149165
150166/** 
@@ -160,7 +176,7 @@ function coerceVariableValues(
160176export  function  getArgumentValues ( 
161177  def : GraphQLField < mixed ,  mixed >  |  GraphQLDirective , 
162178  node : FieldNode  |  DirectiveNode , 
163-   variableValues ?: ?ObjMap < mixed > , 
179+   variableValues ?: ?VariableValues , 
164180) : {  [ argument : string ] : mixed ,  ... }  { 
165181  const  coercedValues =  { } ; 
166182
@@ -196,7 +212,7 @@ export function getArgumentValues(
196212      const  variableName =  valueNode . name . value ; 
197213      if  ( 
198214        variableValues  ==  null  || 
199-         ! hasOwnProperty ( variableValues ,   variableName ) 
215+         variableValues . coerced [ variableName ]   ===   undefined 
200216      )  { 
201217        if  ( argDef . defaultValue )  { 
202218          coercedValues [ name ]  =  getCoercedDefaultValue ( 
@@ -212,7 +228,7 @@ export function getArgumentValues(
212228        } 
213229        continue ; 
214230      } 
215-       isNull  =  variableValues [ variableName ]  ==  null ; 
231+       isNull  =  variableValues . coerced [ variableName ]  ==  null ; 
216232    } 
217233
218234    if  ( isNull  &&  isNonNullType ( argType ) )  { 
@@ -252,7 +268,7 @@ export function getArgumentValues(
252268export  function  getDirectiveValues ( 
253269  directiveDef : GraphQLDirective , 
254270  node : {  + directives ?: $ReadOnlyArray < DirectiveNode > ,  ... } , 
255-   variableValues ?: ?ObjMap < mixed > , 
271+   variableValues ?: ?VariableValues , 
256272) : void  |  {  [ argument : string ] : mixed ,  ... }  { 
257273  // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203') 
258274  const  directiveNode =  node . directives ?. find ( 
0 commit comments