From 85eaa4b391f12bee993ab4a3c4831c1cfd2fe205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 23 May 2022 11:23:56 +0200 Subject: [PATCH] Refactor to use filters in query listTransactionLinksAdmin --- backend/src/graphql/arg/SearchUsersFilters.ts | 4 +-- .../src/graphql/arg/TransactionLinkFilters.ts | 10 +++---- backend/src/graphql/resolver/AdminResolver.ts | 2 +- backend/src/seeds/graphql/mutations.ts | 29 +++++++++++++++++++ 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/backend/src/graphql/arg/SearchUsersFilters.ts b/backend/src/graphql/arg/SearchUsersFilters.ts index efcdfa00d..dc19d456c 100644 --- a/backend/src/graphql/arg/SearchUsersFilters.ts +++ b/backend/src/graphql/arg/SearchUsersFilters.ts @@ -3,8 +3,8 @@ import { Field, InputType } from 'type-graphql' @InputType() export default class SearchUsersFilters { @Field(() => Boolean, { nullable: true, defaultValue: null }) - byActivated?: boolean | null + byActivated: boolean @Field(() => Boolean, { nullable: true, defaultValue: null }) - byDeleted?: boolean | null + byDeleted: boolean } diff --git a/backend/src/graphql/arg/TransactionLinkFilters.ts b/backend/src/graphql/arg/TransactionLinkFilters.ts index 98c12703e..0fdd5c7c6 100644 --- a/backend/src/graphql/arg/TransactionLinkFilters.ts +++ b/backend/src/graphql/arg/TransactionLinkFilters.ts @@ -1,13 +1,13 @@ -import { ArgsType, Field } from 'type-graphql' +import { Field, InputType } from 'type-graphql' -@ArgsType() +@InputType() export default class TransactionLinkFilters { @Field(() => Boolean, { nullable: true, defaultValue: true }) - byDeleted?: boolean + byDeleted: boolean @Field(() => Boolean, { nullable: true, defaultValue: true }) - byExpired?: boolean + byExpired: boolean @Field(() => Boolean, { nullable: true, defaultValue: true }) - byRedeemed?: boolean + byRedeemed: boolean } diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 4aec5ca67..7aa5cd079 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -426,7 +426,7 @@ export class AdminResolver { async listTransactionLinksAdmin( @Args() { currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated, - @Args() + @Arg('filters') filters: TransactionLinkFilters, @Arg('userId', () => Int) userId: number, ): Promise { diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index 982de3bcc..07bc46b03 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -163,3 +163,32 @@ export const deletePendingCreation = gql` deletePendingCreation(id: $id) } ` + +export const listTransactionLinksAdmin = gql` + query ( + $userId: Int! + $filters: TransactionLinkFilters! + $currentPage: Int = 1 + $pageSize: Int = 5 + ) { + listTransactionLinksAdmin( + userId: $userId + filters: $filters + currentPage: $currentPage + pageSize: $pageSize + ) { + linkCount + linkList { + id + amount + holdAvailableAmount + memo + code + createdAt + validUntil + redeemedAt + deletedAt + } + } + } +`