Skip to content

Commit

Permalink
feat: add delete join request operation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Smith committed Mar 1, 2024
1 parent e2a2ae6 commit a1e8112
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions appsync.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export type LocalAuthorityUser = {

export type Mutation = {
__typename?: 'Mutation';
deleteDeniedJoinRequest: Scalars['Boolean']['output'];
insertItemQuery: Scalars['Boolean']['output'];
insertJoinRequest: Scalars['Boolean']['output'];
insertLocalAuthorityRegisterRequest: Scalars['Boolean']['output'];
Expand All @@ -114,6 +115,11 @@ export type Mutation = {
};


export type MutationDeleteDeniedJoinRequestArgs = {
name: Scalars['String']['input'];
};


export type MutationInsertItemQueryArgs = {
connection?: InputMaybe<Scalars['String']['input']>;
email: Scalars['String']['input'];
Expand Down
2 changes: 2 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ type Mutation {
phone: String!
connection: String
): Boolean!

deleteDeniedJoinRequest(name: String!): Boolean!
}

schema {
Expand Down
8 changes: 8 additions & 0 deletions src/handlers/privateResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
MutationInsertJoinRequestArgs,
MutationInsertItemQueryArgs,
MutationInsertLocalAuthorityRegisterRequestArgs,
MutationDeleteDeniedJoinRequestArgs,
} from '../../appsync';
import { logger } from '../shared/logger';
import { LocalAuthorityDataRepository } from '../repository/localAuthorityDataRepository';
Expand All @@ -33,6 +34,7 @@ export const handler: AppSyncResolverHandler<
| MutationUpdateJoinRequestArgs
| MutationInsertItemQueryArgs
| MutationInsertJoinRequestArgs
| MutationDeleteDeniedJoinRequestArgs
| MutationInsertLocalAuthorityRegisterRequestArgs,
boolean
> = async (event, context, callback) => {
Expand Down Expand Up @@ -110,6 +112,12 @@ export const handler: AppSyncResolverHandler<
callback(null, res);
break;
}
case 'deleteDeniedJoinRequest': {
const { name } = params as MutationDeleteDeniedJoinRequestArgs;
const res = await joinRequestsRepository.deleteDenied(name);
callback(null, res);
break;
}

default: {
callback(`Unexpected type ${info.fieldName}`);
Expand Down
4 changes: 4 additions & 0 deletions src/repository/joinRequestsRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,8 @@ export class JoinRequestsRepository {
public async insert(user: JoinRequest): Promise<boolean> {
return (await this.collection.insertOne(user)).acknowledged;
}

public async deleteDenied(name: string): Promise<boolean> {
return (await this.collection.deleteOne({ name, status: 'DENIED' })).acknowledged;
}
}

0 comments on commit a1e8112

Please sign in to comment.