@@ -228,12 +228,13 @@ describe('validateInputValue', () => {
228228 } ) ;
229229
230230 describe ( 'for GraphQLInputObject' , ( ) => {
231- const TestInputObject = new GraphQLInputObjectType ( {
231+ const TestInputObject : GraphQLInputObjectType = new GraphQLInputObjectType ( {
232232 name : 'TestInputObject' ,
233- fields : {
233+ fields : ( ) => ( {
234234 foo : { type : new GraphQLNonNull ( GraphQLInt ) } ,
235235 bar : { type : GraphQLInt } ,
236- } ,
236+ nested : { type : TestInputObject } ,
237+ } ) ,
237238 } ) ;
238239
239240 it ( 'returns no error for a valid input' , ( ) => {
@@ -292,6 +293,30 @@ describe('validateInputValue', () => {
292293 ] ) ;
293294 } ) ;
294295
296+ it ( 'returns error when supplied with an array' , ( ) => {
297+ test ( [ { foo : 123 } , { bar : 456 } ] , TestInputObject , [
298+ {
299+ error :
300+ 'Expected value of type "TestInputObject" to be an object, found: [{ foo: 123 }, { bar: 456 }].' ,
301+ path : [ ] ,
302+ } ,
303+ ] ) ;
304+ } ) ;
305+
306+ it ( 'returns error when a nested input object is supplied with an array' , ( ) => {
307+ test (
308+ { foo : 123 , nested : [ { foo : 123 } , { bar : 456 } ] } ,
309+ TestInputObject ,
310+ [
311+ {
312+ error :
313+ 'Expected value of type "TestInputObject" to be an object, found: [{ foo: 123 }, { bar: 456 }].' ,
314+ path : [ 'nested' ] ,
315+ } ,
316+ ] ,
317+ ) ;
318+ } ) ;
319+
295320 it ( 'returns error for a misspelled field' , ( ) => {
296321 test ( { foo : 123 , bart : 123 } , TestInputObject , [
297322 {
0 commit comments