@@ -68,6 +68,16 @@ interface GetUserResponse {
6868 user : User ;
6969}
7070
71+ interface InsertUserVariables {
72+ id : string ;
73+ name : string ;
74+ address : string ;
75+ }
76+
77+ interface InsertUserResponse {
78+ user_insert : { id : string ; } ;
79+ }
80+
7181interface ListUsersResponse {
7282 users : User [ ] ;
7383}
@@ -487,11 +497,10 @@ describe('getDataConnect()', () => {
487497 ) . should . eventually . be . rejected . and . have . property ( 'code' , 'data-connect/not-found' ) ;
488498 } )
489499
490- it ( 'should execut a query with variables' , async ( ) => {
500+ it ( 'should execute a query with variables' , async ( ) => {
491501 const resp = await getDataConnect ( connectorConfig ) . executeQuery < GetUserResponse , GetUserVariables > (
492502 'GetUser' ,
493503 { id : { id : fredUser . id } } ,
494- optsUnauthorizedClaims ,
495504 ) ;
496505 expect ( resp . data . user ) . to . not . be . empty ;
497506 expect ( resp . data . user ) . to . deep . equal ( fredUser ) ;
@@ -777,6 +786,21 @@ describe('getDataConnect()', () => {
777786 return getDataConnect ( connectorConfig ) . executeMutation (
778787 'DOES_NOT_EXIST!!!' , optsUnauthorizedClaims
779788 ) . should . eventually . be . rejected . and . have . property ( 'code' , 'data-connect/not-found' ) ;
789+ } ) ;
790+
791+ it ( 'should execute a mutation with variables' , async ( ) => {
792+ const user = { id : 'USER_ID' , name : 'USER_NAME' , address : 'USER_ADDRESS' } ;
793+ const insertResp = await getDataConnect ( connectorConfig )
794+ . executeMutation < InsertUserResponse , InsertUserVariables > ( 'InsertUser' , user ) ;
795+ expect ( insertResp . data . user_insert ) . to . not . be . empty ;
796+ expect ( insertResp . data . user_insert ) . to . deep . equal ( { id : user . id } ) ;
797+
798+ const getResp = await getDataConnect ( connectorConfig ) . executeQuery < GetUserResponse , GetUserVariables > (
799+ 'GetUser' ,
800+ { id : { id : user . id } } ,
801+ ) ;
802+ expect ( getResp . data . user ) . to . not . be . empty ;
803+ expect ( getResp . data . user ) . to . deep . equal ( user ) ;
780804 } )
781805
782806 describe ( 'with unauthenticated impersonation' , ( ) => {
0 commit comments