@@ -664,3 +664,71 @@ test('should handle array field types used for alias field names', async () => {
664
664
const source = parseGraphQLSDL ( `${ virtualFileName } .graphql` , rawSDL ) ;
665
665
expect ( source ) . toBeDefined ( ) ;
666
666
} ) ;
667
+
668
+ test ( 'should work with query with default value arguments' , async ( ) => {
669
+ const document = buildOperationNodeForField ( {
670
+ schema : buildSchema ( /* GraphQL */ `
671
+ input PageInfoInput {
672
+ offset: Int!
673
+ limit: Int!
674
+ }
675
+
676
+ type User {
677
+ id: ID
678
+ name: String
679
+ }
680
+
681
+ type Query {
682
+ # users(pageInfo: PageInfoInput!): [User]
683
+ usersSearch(query: String, offset: Int! = 0, limit: Int! = 10): [User]
684
+ }
685
+ ` ) ,
686
+ kind : 'query' as OperationTypeNode ,
687
+ field : 'usersSearch' ,
688
+ models,
689
+ ignore : [ ] ,
690
+ } ) ! ;
691
+
692
+ expect ( clean ( document ) ) . toEqual (
693
+ clean ( /* GraphQL */ `
694
+ query usersSearch_query($query: String, $offset: Int! = 0, $limit: Int! = 10) {
695
+ usersSearch(query: $query, offset: $offset, limit: $limit) {
696
+ id
697
+ name
698
+ }
699
+ }
700
+ ` )
701
+ ) ;
702
+ } ) ;
703
+
704
+ test ( 'should work with mutation with default value arguments' , async ( ) => {
705
+ const document = buildOperationNodeForField ( {
706
+ schema : buildSchema ( /* GraphQL */ `
707
+ type User {
708
+ id: ID
709
+ name: String
710
+ active: Boolean!
711
+ }
712
+
713
+ type Mutation {
714
+ addUser(name: String!, active: Boolean = true): [User]
715
+ }
716
+ ` ) ,
717
+ kind : 'mutation' as OperationTypeNode ,
718
+ field : 'addUser' ,
719
+ models,
720
+ ignore : [ ] ,
721
+ } ) ! ;
722
+
723
+ expect ( clean ( document ) ) . toEqual (
724
+ clean ( /* GraphQL */ `
725
+ mutation addUser_mutation($name: String!, $active: Boolean = true) {
726
+ addUser(name: $name, active: $active) {
727
+ id
728
+ name
729
+ active
730
+ }
731
+ }
732
+ ` )
733
+ ) ;
734
+ } ) ;
0 commit comments