@@ -42,54 +42,51 @@ import { GraphQLID } from '../type/scalars';
4242 *
4343 */
4444export function astFromValue ( value : mixed , type : GraphQLInputType ) : ?ValueNode {
45- // Ensure flow knows that we treat function params as const.
46- const _value = value ;
47-
4845 if ( isNonNullType ( type ) ) {
49- const astValue = astFromValue ( _value , type . ofType ) ;
46+ const astValue = astFromValue ( value , type . ofType ) ;
5047 if ( astValue && astValue . kind === Kind . NULL ) {
5148 return null ;
5249 }
5350 return astValue ;
5451 }
5552
5653 // only explicit null, not undefined, NaN
57- if ( _value === null ) {
54+ if ( value === null ) {
5855 return { kind : Kind . NULL } ;
5956 }
6057
6158 // undefined, NaN
62- if ( isInvalid ( _value ) ) {
59+ if ( isInvalid ( value ) ) {
6360 return null ;
6461 }
6562
6663 // Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but
6764 // the value is not an array, convert the value using the list's item type.
6865 if ( isListType ( type ) ) {
6966 const itemType = type . ofType ;
70- if ( isCollection ( _value ) ) {
67+ if ( isCollection ( value ) ) {
7168 const valuesNodes = [ ] ;
72- forEach ( ( _value : any ) , item => {
69+ forEach ( ( value : any ) , item => {
7370 const itemNode = astFromValue ( item , itemType ) ;
7471 if ( itemNode ) {
7572 valuesNodes . push ( itemNode ) ;
7673 }
7774 } ) ;
7875 return { kind : Kind . LIST , values : valuesNodes } ;
7976 }
80- return astFromValue ( _value , itemType ) ;
77+ return astFromValue ( value , itemType ) ;
8178 }
8279
8380 // Populate the fields of the input object by creating ASTs from each value
8481 // in the JavaScript object according to the fields in the input type.
8582 if ( isInputObjectType ( type ) ) {
86- if ( _value === null || typeof _value !== 'object' ) {
83+ if ( value === null || typeof value !== 'object' ) {
8784 return null ;
8885 }
8986 const fields = objectValues ( type . getFields ( ) ) ;
9087 const fieldNodes = [ ] ;
9188 fields . forEach ( field => {
92- const fieldValue = astFromValue ( _value [ field . name ] , field . type ) ;
89+ const fieldValue = astFromValue ( value [ field . name ] , field . type ) ;
9390 if ( fieldValue ) {
9491 fieldNodes . push ( {
9592 kind : Kind . OBJECT_FIELD ,
@@ -104,7 +101,7 @@ export function astFromValue(value: mixed, type: GraphQLInputType): ?ValueNode {
104101 if ( isScalarType ( type ) || isEnumType ( type ) ) {
105102 // Since value is an internally represented value, it must be serialized
106103 // to an externally represented value before converting into an AST.
107- const serialized = type . serialize ( _value ) ;
104+ const serialized = type . serialize ( value ) ;
108105 if ( isNullish ( serialized ) ) {
109106 return null ;
110107 }
0 commit comments