Skip to content

Commit

Permalink
Prevent updating message proposal once signed
Browse files Browse the repository at this point in the history
  • Loading branch information
hbriese committed Aug 21, 2023
1 parent f88a814 commit 04e1417
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ID, Info, Mutation, Query, Resolver } from '@nestjs/graphql';
import { ID, Info, Mutation, Parent, Query, Resolver } from '@nestjs/graphql';
import { MessageProposal } from './message-proposals.model';
import { Input } from '~/decorators/input.decorator';
import { ProposeMessageInput } from './message-proposals.input';
Expand All @@ -7,6 +7,7 @@ import { ApproveInput, ProposalInput } from '../proposals/proposals.input';
import { MessageProposalsService } from './message-proposals.service';
import { getShape } from '../database/database.select';
import { ComputedField } from '~/decorators/computed.decorator';
import e from '~/edgeql-js';

@Resolver(() => MessageProposal)
export class MessageProposalsResolver {
Expand All @@ -17,9 +18,9 @@ export class MessageProposalsResolver {
return this.service.selectUnique(input.hash, getShape(info));
}

@ComputedField(() => Boolean, {})
async updatable() {
return true;
@ComputedField<typeof e.MessageProposal>(() => Boolean, { signature: true })
async updatable(@Parent() { signature }: MessageProposal) {
return !!signature;
}

@Mutation(() => MessageProposal)
Expand Down

0 comments on commit 04e1417

Please sign in to comment.