Skip to content

Commit 4e5fbcb

Browse files
committed
address mutation test comments
1 parent e95a035 commit 4e5fbcb

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

test/integration/data-connect.spec.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
7181
interface 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', () => {

test/integration/dataconnect/dataconnect/my-connector/mutations.gql

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
mutation upsertFredUser @auth(level: NO_ACCESS) {
22
user_upsert(data: { id: "fred_id", address: "32 Elm St.", name: "Fred" })
33
}
4-
mutation updateFredrickUserImpersonation @auth(level: USER, insecureReason: "test") {
4+
mutation updateFredrickUserImpersonation
5+
@auth(level: USER, insecureReason: "test") {
56
user_update(
67
key: { id_expr: "auth.uid" }
78
data: { address: "64 Elm St. North", name: "Fredrick" }
@@ -23,6 +24,11 @@ mutation upsertJeffEmail @auth(level: NO_ACCESS) {
2324
)
2425
}
2526

27+
mutation InsertUser($id: String!, $name: String!, $address: String!)
28+
@auth(level: PUBLIC, insecureReason: "test") {
29+
user_insert(data: { id: $id, name: $name, address: $address })
30+
}
31+
2632
mutation InsertEmailPublic($id: String!)
2733
@auth(level: PUBLIC, insecureReason: "test") {
2834
email_insert(
@@ -82,7 +88,8 @@ mutation InsertEmailNoAccess($id: String!) @auth(level: NO_ACCESS) {
8288
}
8389
)
8490
}
85-
mutation InsertEmailImpersonation($id: String!) @auth(level: USER_ANON, insecureReason: "test") {
91+
mutation InsertEmailImpersonation($id: String!)
92+
@auth(level: USER_ANON, insecureReason: "test") {
8693
email_insert(
8794
data: {
8895
id: $id

0 commit comments

Comments
 (0)