Skip to content

Commit

Permalink
Drop deprecated ceremony GQL queries
Browse files Browse the repository at this point in the history
  • Loading branch information
CarsonF committed Oct 8, 2024
1 parent c690f9f commit 65b1cdd
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 118 deletions.
53 changes: 4 additions & 49 deletions src/components/ceremony/ceremony.resolver.ts
Original file line number Diff line number Diff line change
@@ -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<CeremonyLoader>,
): Promise<Ceremony> {
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<CeremonyLoader>,
): Promise<CeremonyListOutput> {
const list = await this.service.list(input, session);
ceremonies.primeAll(list.items);
return list;
}

@Mutation(() => UpdateCeremonyOutput, {
description: 'Update a ceremony',
})
Expand All @@ -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() {}
}
19 changes: 1 addition & 18 deletions src/components/ceremony/ceremony.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -85,15 +79,4 @@ export class CeremonyService {
throw new ServerException('Failed to delete Ceremony');
}
}

async list(
input: CeremonyListInput,
session: Session,
): Promise<CeremonyListOutput> {
const results = await this.repo.list(input, session);
return {
...results,
items: results.items.map((dto) => this.secure(dto, session)),
};
}
}
7 changes: 2 additions & 5 deletions src/components/ceremony/dto/list-ceremony.dto.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -21,6 +21,3 @@ export class CeremonyListInput extends SortablePaginationInput<
@FilterField(() => CeremonyFilters)
readonly filter?: CeremonyFilters;
}

@ObjectType()
export class CeremonyListOutput extends PaginatedList(Ceremony) {}
68 changes: 22 additions & 46 deletions test/engagement.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
Expand All @@ -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();
});
Expand Down Expand Up @@ -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
}
}
}
}
Expand All @@ -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();
});
Expand Down

0 comments on commit 65b1cdd

Please sign in to comment.