@@ -183,11 +183,19 @@ describe('coerceInputValue', () => {
183183 } ) ;
184184
185185 describe ( 'for GraphQLInputObject' , ( ) => {
186+ const DeepObject = new GraphQLInputObjectType ( {
187+ name : 'DeepObject' ,
188+ fields : {
189+ foo : { type : new GraphQLNonNull ( GraphQLInt ) } ,
190+ bar : { type : GraphQLInt } ,
191+ } ,
192+ } ) ;
186193 const TestInputObject = new GraphQLInputObjectType ( {
187194 name : 'TestInputObject' ,
188195 fields : {
189196 foo : { type : new GraphQLNonNull ( GraphQLInt ) } ,
190197 bar : { type : GraphQLInt } ,
198+ deepObject : { type : DeepObject } ,
191199 } ,
192200 } ) ;
193201
@@ -271,6 +279,31 @@ describe('coerceInputValue', () => {
271279 } ,
272280 ] ) ;
273281 } ) ;
282+
283+ it ( 'returns an error for an array type' , ( ) => {
284+ const result = coerceValue ( [ { foo : 1 } , { bar : 1 } ] , TestInputObject ) ;
285+ expectErrors ( result ) . to . deep . equal ( [
286+ {
287+ error : 'Expected type "TestInputObject" to be an object.' ,
288+ path : [ ] ,
289+ value : [ { foo : 1 } , { bar : 1 } ] ,
290+ } ,
291+ ] ) ;
292+ } ) ;
293+
294+ it ( 'returns an error for an array type on a nested field' , ( ) => {
295+ const result = coerceValue (
296+ { foo : 1 , deepObject : [ 1 , 2 , 3 ] } ,
297+ TestInputObject ,
298+ ) ;
299+ expectErrors ( result ) . to . deep . equal ( [
300+ {
301+ error : 'Expected type "DeepObject" to be an object.' ,
302+ path : [ 'deepObject' ] ,
303+ value : [ 1 , 2 , 3 ] ,
304+ } ,
305+ ] ) ;
306+ } ) ;
274307 } ) ;
275308
276309 describe ( 'for GraphQLInputObject that isOneOf' , ( ) => {
0 commit comments