@@ -726,6 +726,97 @@ describe('Type System: Input Objects must have fields', () => {
726
726
} ) ;
727
727
728
728
729
+ describe ( 'Type System: Input Object fields must not have resolvers' , ( ) => {
730
+
731
+ function schemaWithInputObject ( inputObjectType ) {
732
+ return new GraphQLSchema ( {
733
+ query : new GraphQLObjectType ( {
734
+ name : 'Query' ,
735
+ fields : {
736
+ f : {
737
+ type : GraphQLString ,
738
+ args : {
739
+ input : { type : inputObjectType }
740
+ }
741
+ }
742
+ }
743
+ } )
744
+ } ) ;
745
+ }
746
+
747
+ it ( 'accepts an Input Object type with no resolver' , ( ) => {
748
+ expect (
749
+ ( ) => schemaWithInputObject ( new GraphQLInputObjectType ( {
750
+ name : 'SomeInputObject' ,
751
+ fields : {
752
+ f : {
753
+ type : GraphQLString ,
754
+ }
755
+ }
756
+ } ) )
757
+ ) . not . to . throw ( ) ;
758
+ } ) ;
759
+
760
+ it ( 'accepts an Input Object type with null resolver' , ( ) => {
761
+ expect (
762
+ ( ) => schemaWithInputObject ( new GraphQLInputObjectType ( {
763
+ name : 'SomeInputObject' ,
764
+ fields : {
765
+ f : {
766
+ type : GraphQLString ,
767
+ resolve : null ,
768
+ }
769
+ }
770
+ } ) )
771
+ ) . not . to . throw ( ) ;
772
+ } ) ;
773
+
774
+ it ( 'accepts an Input Object type with undefined resolver' , ( ) => {
775
+ expect (
776
+ ( ) => schemaWithInputObject ( new GraphQLInputObjectType ( {
777
+ name : 'SomeInputObject' ,
778
+ fields : {
779
+ f : {
780
+ type : GraphQLString ,
781
+ resolve : undefined ,
782
+ }
783
+ }
784
+ } ) )
785
+ ) . not . to . throw ( ) ;
786
+ } ) ;
787
+
788
+ it ( 'rejects an Input Object type with resolver function' , ( ) => {
789
+ expect (
790
+ ( ) => schemaWithInputObject ( new GraphQLInputObjectType ( {
791
+ name : 'SomeInputObject' ,
792
+ fields : {
793
+ f : {
794
+ type : GraphQLString ,
795
+ resolve : ( ) => { return 0 ; } ,
796
+ }
797
+ }
798
+ } ) )
799
+ ) . to . throw ( 'SomeInputObject.f field type has a resolve property,' +
800
+ ' but Input Types cannot define resolvers.' ) ;
801
+ } ) ;
802
+
803
+ it ( 'rejects an Input Object type with resolver constant' , ( ) => {
804
+ expect (
805
+ ( ) => schemaWithInputObject ( new GraphQLInputObjectType ( {
806
+ name : 'SomeInputObject' ,
807
+ fields : {
808
+ f : {
809
+ type : GraphQLString ,
810
+ resolve : { } ,
811
+ }
812
+ }
813
+ } ) )
814
+ ) . to . throw ( 'SomeInputObject.f field type has a resolve property,' +
815
+ ' but Input Types cannot define resolvers.' ) ;
816
+ } ) ;
817
+ } ) ;
818
+
819
+
729
820
describe ( 'Type System: Object types must be assertable' , ( ) => {
730
821
731
822
it ( 'accepts an Object type with an isTypeOf function' , ( ) => {
0 commit comments