From e1c239cd08f8c65bfcfd0eec9cdb8d8f8b645f48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Wed, 15 Mar 2023 01:25:34 +0100 Subject: [PATCH] rework PR-comments --- backend/src/auth/RIGHTS.ts | 1 - .../resolver/CommunityResolver.test.ts | 20 ++----------------- .../src/graphql/resolver/CommunityResolver.ts | 9 +++------ backend/src/seeds/graphql/queries.ts | 16 +++++++++++++++ 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/backend/src/auth/RIGHTS.ts b/backend/src/auth/RIGHTS.ts index 22be48e40..7ee60dbe5 100644 --- a/backend/src/auth/RIGHTS.ts +++ b/backend/src/auth/RIGHTS.ts @@ -2,7 +2,6 @@ export enum RIGHTS { LOGIN = 'LOGIN', VERIFY_LOGIN = 'VERIFY_LOGIN', BALANCE = 'BALANCE', - GET_COMMUNITY_INFO = 'GET_COMMUNITY_INFO', COMMUNITIES = 'COMMUNITIES', LIST_GDT_ENTRIES = 'LIST_GDT_ENTRIES', EXIST_PID = 'EXIST_PID', diff --git a/backend/src/graphql/resolver/CommunityResolver.test.ts b/backend/src/graphql/resolver/CommunityResolver.test.ts index 13a9bb4dc..1e8f6a00f 100644 --- a/backend/src/graphql/resolver/CommunityResolver.test.ts +++ b/backend/src/graphql/resolver/CommunityResolver.test.ts @@ -1,14 +1,14 @@ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/unbound-method */ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +import { getCommunities } from '@/seeds/graphql/queries' import { Community as DbCommunity } from '@entity/Community' import { testEnvironment } from '@test/helpers' -// jest.mock('@/config') - let query: any // to do: We need a setup for the tests that closes the connection @@ -27,22 +27,6 @@ afterAll(async () => { }) describe('CommunityResolver', () => { - const getCommunities = ` - query { - getCommunities { - id - foreign - publicKey - url - lastAnnouncedAt - verifiedAt - lastErrorAt - createdAt - updatedAt - } - } - ` - describe('getCommunities', () => { let homeCom1: DbCommunity let homeCom2: DbCommunity diff --git a/backend/src/graphql/resolver/CommunityResolver.ts b/backend/src/graphql/resolver/CommunityResolver.ts index 1bb0d3c64..1292fa55f 100644 --- a/backend/src/graphql/resolver/CommunityResolver.ts +++ b/backend/src/graphql/resolver/CommunityResolver.ts @@ -10,12 +10,9 @@ export class CommunityResolver { @Authorized([RIGHTS.COMMUNITIES]) @Query(() => [Community]) async getCommunities(): Promise { - const comList: Community[] = [] - const dbCommunities: DbCommunity[] = await DbCommunity.find({ order: { id: 'ASC' } }) - dbCommunities.forEach(async function (dbCom) { - const com = new Community(dbCom) - comList.push(com) + const dbCommunities: DbCommunity[] = await DbCommunity.find({ + order: { foreign: 'ASC', publicKey: 'ASC', apiVersion: 'ASC' }, }) - return comList + return dbCommunities.map((dbCom: DbCommunity) => new Community(dbCom)) } } diff --git a/backend/src/seeds/graphql/queries.ts b/backend/src/seeds/graphql/queries.ts index 299a0103d..1d1cea823 100644 --- a/backend/src/seeds/graphql/queries.ts +++ b/backend/src/seeds/graphql/queries.ts @@ -133,6 +133,22 @@ export const communities = gql` } ` +export const getCommunities = gql` + query { + getCommunities { + id + foreign + publicKey + url + lastAnnouncedAt + verifiedAt + lastErrorAt + createdAt + updatedAt + } + } +` + export const queryTransactionLink = gql` query ($code: String!) { queryTransactionLink(code: $code) {