@@ -546,19 +546,42 @@ private static class TestInputArgument {
546
546
@ GraphQLField
547
547
public int b ;
548
548
549
- public TestInputArgument (HashMap < String , Object > args ) {
550
- a = ( String ) args . get ( "a" ) ;
551
- b = ( int ) args . get ( "b" ) ;
549
+ public TestInputArgument (String a , int b ) {
550
+ this . a = a ;
551
+ this . b = b ;
552
552
}
553
553
}
554
554
555
+ private static class TestComplexInputArgument {
556
+
557
+ public Collection <TestInputArgument > inputs ;
558
+
559
+ public TestComplexInputArgument (Collection <TestInputArgument > inputs ) {
560
+ this .inputs = inputs ;
561
+ }
562
+
563
+ @ GraphQLField
564
+ public Collection <TestInputArgument > getInputs () {
565
+ return inputs ;
566
+ }
567
+
568
+ }
569
+
570
+
571
+
555
572
private static class TestObjectInput {
556
573
@ GraphQLField
557
574
public String test (int other , TestInputArgument arg ) {
558
575
return arg .a ;
559
576
}
577
+
578
+ @ GraphQLField
579
+ public String test2 (int other , TestComplexInputArgument arg ) {
580
+ return arg .inputs .iterator ().next ().a ;
581
+ }
560
582
}
561
583
584
+
562
585
@ Test
563
586
public void inputObjectArgument () {
564
587
GraphQLObjectType object = GraphQLAnnotations .object (TestObjectInput .class );
@@ -573,6 +596,20 @@ public void inputObjectArgument() {
573
596
assertEquals (v .get ("test" ), "ok" );
574
597
}
575
598
599
+ @ Test
600
+ public void complexInputObjectArgument () {
601
+ GraphQLObjectType object = GraphQLAnnotations .object (TestObjectInput .class );
602
+ GraphQLArgument argument = object .getFieldDefinition ("test2" ).getArgument ("arg" );
603
+ assertTrue (argument .getType () instanceof GraphQLInputObjectType );
604
+ assertEquals (argument .getName (), "arg" );
605
+
606
+ GraphQLSchema schema = newSchema ().query (object ).build ();
607
+ ExecutionResult result = GraphQL .newGraphQL (schema ).build ().execute ("{ test2(arg: {inputs:[{ a:\" ok\" , b:2 }]}, other:0) }" , new TestObjectInput ());
608
+ assertTrue (result .getErrors ().isEmpty ());
609
+ Map <String , Object > v = (Map <String , Object >) result .getData ();
610
+ assertEquals (v .get ("test2" ), "ok" );
611
+ }
612
+
576
613
@ Test
577
614
public void inputObject () {
578
615
GraphQLObjectType object = GraphQLAnnotations .object (TestObjectInput .class );
0 commit comments