File tree Expand file tree Collapse file tree 5 files changed +14
-11
lines changed
Expand file tree Collapse file tree 5 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -55,17 +55,17 @@ describe('updateById() ->', () => {
5555 describe ( 'Resolver.args' , ( ) => {
5656 it ( 'should have `input` arg' , ( ) => {
5757 const resolver = updateById ( UserModel , UserType ) ;
58- expect ( resolver . hasArg ( 'input' ) ) . to . be . true ;
5958 const argConfig = resolver . getArg ( 'input' ) ;
60- expect ( argConfig ) . has . deep . property ( 'type.name' , 'UpdateByIdUserInput' ) ;
59+ expect ( argConfig ) . property ( 'type' ) . instanceof ( GraphQLNonNull ) ;
60+ expect ( argConfig ) . deep . property ( 'type.ofType.name' , 'UpdateByIdUserInput' ) ;
6161 } ) ;
6262
6363 it ( 'should have `input._id` required arg' , ( ) => {
6464 const resolver = updateById ( UserModel , UserType ) ;
6565 const argConfig = resolver . getArg ( 'input' ) || { } ;
66- expect ( argConfig ) . property ( 'type' ) . instanceof ( GraphQLInputObjectType ) ;
67- if ( argConfig . type ) {
68- const _idFieldType = new InputTypeComposer ( argConfig . type ) . getFieldType ( '_id' ) ;
66+ expect ( argConfig ) . deep . property ( 'type.ofType ' ) . instanceof ( GraphQLInputObjectType ) ;
67+ if ( argConfig . type && argConfig . type . ofType ) {
68+ const _idFieldType = new InputTypeComposer ( argConfig . type . ofType ) . getFieldType ( '_id' ) ;
6969 expect ( _idFieldType ) . instanceof ( GraphQLNonNull ) ;
7070 expect ( getNullableType ( _idFieldType ) ) . equal ( GraphQLMongoID ) ;
7171 }
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import updateMany from '../updateMany';
66import Resolver from '../../../../graphql-compose/src/resolver/resolver' ;
77import TypeComposer from '../../../../graphql-compose/src/typeComposer' ;
88import { convertModelToGraphQL } from '../../fieldsConverter' ;
9- import { GraphQLInt } from 'graphql' ;
9+ import { GraphQLInt , GraphQLNonNull } from 'graphql' ;
1010
1111const UserType = convertModelToGraphQL ( UserModel , 'User' ) ;
1212
@@ -69,9 +69,9 @@ describe('updateMany() ->', () => {
6969
7070 it ( 'should have `input` arg' , ( ) => {
7171 const resolver = updateMany ( UserModel , UserType ) ;
72- expect ( resolver . hasArg ( 'input' ) ) . to . be . true ;
7372 const argConfig = resolver . getArg ( 'input' ) ;
74- expect ( argConfig ) . has . deep . property ( 'type.name' , 'UpdateManyUserInput' ) ;
73+ expect ( argConfig ) . property ( 'type' ) . instanceof ( GraphQLNonNull ) ;
74+ expect ( argConfig ) . deep . property ( 'type.ofType.name' , 'UpdateManyUserInput' ) ;
7575 } ) ;
7676 } ) ;
7777
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import Resolver from '../../../../graphql-compose/src/resolver/resolver';
77import TypeComposer from '../../../../graphql-compose/src/typeComposer' ;
88import { convertModelToGraphQL } from '../../fieldsConverter' ;
99import GraphQLMongoID from '../../types/mongoid' ;
10+ import { GraphQLNonNull } from 'graphql/type' ;
1011
1112const UserType = convertModelToGraphQL ( UserModel , 'User' ) ;
1213
@@ -62,11 +63,11 @@ describe('updateOne() ->', () => {
6263 expect ( resolver . hasArg ( 'sort' ) ) . to . be . true ;
6364 } ) ;
6465
65- it ( 'should have `input` arg' , ( ) => {
66+ it ( 'should have required `input` arg' , ( ) => {
6667 const resolver = updateOne ( UserModel , UserType ) ;
67- expect ( resolver . hasArg ( 'input' ) ) . to . be . true ;
6868 const argConfig = resolver . getArg ( 'input' ) ;
69- expect ( argConfig ) . has . deep . property ( 'type.name' , 'UpdateOneUserInput' ) ;
69+ expect ( argConfig ) . property ( 'type' ) . instanceof ( GraphQLNonNull ) ;
70+ expect ( argConfig ) . deep . property ( 'type.ofType.name' , 'UpdateOneUserInput' ) ;
7071 } ) ;
7172 } ) ;
7273
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ export default function updateMany(
3737 ...inputHelperArgsGen ( gqType , {
3838 inputTypeName : `UpdateMany${ gqType . name } Input` ,
3939 removeFields : [ 'id' , '_id' ] ,
40+ isRequired : true ,
4041 } ) ,
4142 ...filterHelperArgsGen ( model , {
4243 filterTypeName : `Filter${ gqType . name } Input` ,
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ export default function updateOne(
4545 ...inputHelperArgsGen ( gqType , {
4646 inputTypeName : `UpdateOne${ gqType . name } Input` ,
4747 removeFields : [ 'id' , '_id' ] ,
48+ isRequired : true ,
4849 } ) ,
4950 ...filterHelperArgsGen ( model , {
5051 filterTypeName : `Filter${ gqType . name } Input` ,
You can’t perform that action at this time.
0 commit comments