diff --git a/src/components/ceremony/ceremony.resolver.ts b/src/components/ceremony/ceremony.resolver.ts index b1c83b5a62..086d35ea0a 100644 --- a/src/components/ceremony/ceremony.resolver.ts +++ b/src/components/ceremony/ceremony.resolver.ts @@ -1,51 +1,12 @@ -import { Args, Mutation, Query, Resolver } from '@nestjs/graphql'; -import { - AnonSession, - ID, - IdArg, - ListArg, - LoggedInSession, - Session, -} from '~/common'; -import { Loader, LoaderOf } from '~/core'; -import { CeremonyLoader, CeremonyService } from '../ceremony'; -import { - Ceremony, - CeremonyListInput, - CeremonyListOutput, - UpdateCeremonyInput, - UpdateCeremonyOutput, -} from './dto'; +import { Args, Mutation, Resolver } from '@nestjs/graphql'; +import { LoggedInSession, Session } from '~/common'; +import { CeremonyService } from '../ceremony'; +import { UpdateCeremonyInput, UpdateCeremonyOutput } from './dto'; @Resolver() export class CeremonyResolver { constructor(private readonly service: CeremonyService) {} - @Query(() => Ceremony, { - description: 'Look up a ceremony by its ID', - deprecationReason: 'Query via engagement instead', - }) - async ceremony( - @IdArg() id: ID, - @Loader(CeremonyLoader) ceremonies: LoaderOf, - ): Promise { - return await ceremonies.load(id); - } - - @Query(() => CeremonyListOutput, { - description: 'Look up ceremonies', - deprecationReason: 'Query via engagement instead', - }) - async ceremonies( - @AnonSession() session: Session, - @ListArg(CeremonyListInput) input: CeremonyListInput, - @Loader(CeremonyLoader) ceremonies: LoaderOf, - ): Promise { - const list = await this.service.list(input, session); - ceremonies.primeAll(list.items); - return list; - } - @Mutation(() => UpdateCeremonyOutput, { description: 'Update a ceremony', }) @@ -56,10 +17,4 @@ export class CeremonyResolver { const ceremony = await this.service.update(input, session); return { ceremony }; } - - // Ceremonies are created automatically via engagements - // async createCeremony() {} - - // Ceremonies are deleted automatically via engagements - // async deleteCeremony() {} } diff --git a/src/components/ceremony/ceremony.service.ts b/src/components/ceremony/ceremony.service.ts index f871581491..60216fc346 100644 --- a/src/components/ceremony/ceremony.service.ts +++ b/src/components/ceremony/ceremony.service.ts @@ -10,13 +10,7 @@ import { import { HandleIdLookup, ILogger, Logger } from '~/core'; import { Privileges } from '../authorization'; import { CeremonyRepository } from './ceremony.repository'; -import { - Ceremony, - CeremonyListInput, - CeremonyListOutput, - CreateCeremony, - UpdateCeremony, -} from './dto'; +import { Ceremony, CreateCeremony, UpdateCeremony } from './dto'; @Injectable() export class CeremonyService { @@ -85,15 +79,4 @@ export class CeremonyService { throw new ServerException('Failed to delete Ceremony'); } } - - async list( - input: CeremonyListInput, - session: Session, - ): Promise { - const results = await this.repo.list(input, session); - return { - ...results, - items: results.items.map((dto) => this.secure(dto, session)), - }; - } } diff --git a/src/components/ceremony/dto/list-ceremony.dto.ts b/src/components/ceremony/dto/list-ceremony.dto.ts index 00cccbe6c2..78f5672802 100644 --- a/src/components/ceremony/dto/list-ceremony.dto.ts +++ b/src/components/ceremony/dto/list-ceremony.dto.ts @@ -1,5 +1,5 @@ -import { Field, InputType, ObjectType } from '@nestjs/graphql'; -import { FilterField, PaginatedList, SortablePaginationInput } from '~/common'; +import { Field, InputType } from '@nestjs/graphql'; +import { FilterField, SortablePaginationInput } from '~/common'; import { CeremonyType } from './ceremony-type.enum'; import { Ceremony } from './ceremony.dto'; @@ -21,6 +21,3 @@ export class CeremonyListInput extends SortablePaginationInput< @FilterField(() => CeremonyFilters) readonly filter?: CeremonyFilters; } - -@ObjectType() -export class CeremonyListOutput extends PaginatedList(Ceremony) {} diff --git a/test/engagement.e2e-spec.ts b/test/engagement.e2e-spec.ts index a10480fc4e..d7681d2162 100644 --- a/test/engagement.e2e-spec.ts +++ b/test/engagement.e2e-spec.ts @@ -569,12 +569,20 @@ describe('Engagement e2e', () => { await registerUser(app, { roles: [Role.FieldOperationsDirector] }); const date = '2020-05-13'; - await app.graphql.mutate( + const result = await app.graphql.mutate( gql` mutation updateCeremony($input: UpdateCeremonyInput!) { updateCeremony(input: $input) { ceremony { id + planned { + value + } + estimatedDate { + value + canRead + canEdit + } } } } @@ -589,28 +597,8 @@ describe('Engagement e2e', () => { }, }, ); - const result = await app.graphql.query( - gql` - query ceremony($id: ID!) { - ceremony(id: $id) { - id - planned { - value - } - estimatedDate { - value - canRead - canEdit - } - } - } - `, - { - id: languageEngagementRead?.engagement?.ceremony?.value?.id, - }, - ); - expect(result.ceremony.planned.value).toBeTruthy(); - expect(result.ceremony.estimatedDate.value).toBe(date); + expect(result.updateCeremony.ceremony.planned.value).toBeTruthy(); + expect(result.updateCeremony.ceremony.estimatedDate.value).toBe(date); await user.login(); }); @@ -645,12 +633,20 @@ describe('Engagement e2e', () => { await registerUser(app, { roles: [Role.FieldOperationsDirector] }); const date = '2020-05-13'; - await app.graphql.mutate( + const result = await app.graphql.mutate( gql` mutation updateCeremony($input: UpdateCeremonyInput!) { updateCeremony(input: $input) { ceremony { id + planned { + value + } + estimatedDate { + value + canRead + canEdit + } } } } @@ -665,28 +661,8 @@ describe('Engagement e2e', () => { }, }, ); - const result = await app.graphql.query( - gql` - query ceremony($id: ID!) { - ceremony(id: $id) { - id - planned { - value - } - estimatedDate { - value - canRead - canEdit - } - } - } - `, - { - id: internshipEngagementRead?.engagement?.ceremony?.value?.id, - }, - ); - expect(result.ceremony.planned.value).toBeTruthy(); - expect(result.ceremony.estimatedDate.value).toBe(date); + expect(result.updateCeremony.ceremony.planned.value).toBeTruthy(); + expect(result.updateCeremony.ceremony.estimatedDate.value).toBe(date); await user.login(); });