@@ -47,7 +47,7 @@ public VariableCollection CreateValues(
4747 _operation . VariableDefinitions )
4848 {
4949 Variable variable = CreateVariable ( variableDefinition ) ;
50- CoerceVariableValue ( values , ref variable ) ;
50+ variable = CoerceVariableValue ( values , variable ) ;
5151 coercedValues [ variable . Name ] = variable . ParseLiteral ( ) ;
5252 }
5353
@@ -73,35 +73,14 @@ private Variable CreateVariable(
7373 variableName ) ) ;
7474 }
7575
76- private void CoerceVariableValue (
76+ private Variable CoerceVariableValue (
7777 IReadOnlyDictionary < string , object > variableValues ,
78- ref Variable variable )
78+ Variable variable )
7979 {
8080 IValueNode valueNode = null ;
8181 if ( variableValues . TryGetValue ( variable . Name , out var rawValue ) )
8282 {
83- object value = rawValue ;
84-
85- if ( rawValue is ICollection < KeyValuePair < string , object > > dict )
86- {
87- var ctx = new DeserializationContext ( ) ;
88- ctx . Type = variable . Type . ClrType ;
89-
90- var converter = new DictionaryToObjectConverter ( ) ;
91- converter . VisitObject ( dict , ctx ) ;
92- value = ctx . Object ;
93- }
94-
95- if ( ! ( value is IValueNode )
96- && variable . Type is ISerializableType st
97- && ! variable . Type . ClrType . IsInstanceOfType ( value ) )
98- {
99- value = st . Deserialize ( value ) ;
100- }
101-
102- valueNode = ( value is IValueNode v )
103- ? v
104- : variable . Type . ParseValue ( value ) ;
83+ valueNode = Normalize ( variable , rawValue ) ;
10584 }
10685 else
10786 {
@@ -113,9 +92,36 @@ private void CoerceVariableValue(
11392
11493 CheckForNullValueViolation ( variable ) ;
11594 CheckForInvalidValueType ( variable ) ;
95+
96+ return variable ;
11697 }
11798
99+ private IValueNode Normalize ( Variable variable , object rawValue )
100+ {
101+ object value = rawValue ;
102+
103+ if ( rawValue is ICollection < KeyValuePair < string , object > >
104+ || rawValue is IList < object > )
105+ {
106+ var ctx = new DeserializationContext ( ) ;
107+ ctx . Type = variable . Type . ClrType ;
108+
109+ var converter = new DictionaryToObjectConverter ( ) ;
110+ converter . Visit ( rawValue , ctx ) ;
111+ value = ctx . Object ;
112+ }
118113
114+ if ( ! ( value is IValueNode )
115+ && variable . Type is ISerializableType st
116+ && ! variable . Type . ClrType . IsInstanceOfType ( value ) )
117+ {
118+ value = st . Deserialize ( value ) ;
119+ }
120+
121+ return ( value is IValueNode v )
122+ ? v
123+ : variable . Type . ParseValue ( value ) ;
124+ }
119125
120126 private IValueNode CleanUpValue ( IInputType type , IValueNode value )
121127 {
0 commit comments