@@ -183,11 +183,19 @@ describe('coerceInputValue', () => {
183
183
} ) ;
184
184
185
185
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
+ } ) ;
186
193
const TestInputObject = new GraphQLInputObjectType ( {
187
194
name : 'TestInputObject' ,
188
195
fields : {
189
196
foo : { type : new GraphQLNonNull ( GraphQLInt ) } ,
190
197
bar : { type : GraphQLInt } ,
198
+ deepObject : { type : DeepObject } ,
191
199
} ,
192
200
} ) ;
193
201
@@ -271,6 +279,31 @@ describe('coerceInputValue', () => {
271
279
} ,
272
280
] ) ;
273
281
} ) ;
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
+ } ) ;
274
307
} ) ;
275
308
276
309
describe ( 'for GraphQLInputObject that isOneOf' , ( ) => {
0 commit comments