Skip to content

Commit

Permalink
Don't throw if added org member already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
rmunn committed Jun 10, 2024
1 parent ed45fe8 commit f47d4df
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions backend/LexBoxApi/GraphQL/OrgMutations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public async Task<IQueryable<Organization>> CreateOrganization(string name,

[Error<DbError>]
[Error<NotFoundException>]
[Error<AlreadyExistsException>]
[UseMutationConvention]
[UseFirstOrDefault]
[UseProjection]
Expand All @@ -57,7 +56,8 @@ public async Task<IQueryable<Organization>> AcquireProject(

if (await dbContext.OrgProjects.AnyAsync(op => op.OrgId == orgId && op.ProjectId == projectId))
{
throw new AlreadyExistsException("Organization already owns this project");
// No error since we're already in desired state; just return early
return dbContext.Orgs.Where(o => o.Id == orgId);
}
await dbContext.OrgProjects.AddAsync(new OrgProjects { OrgId = orgId, ProjectId = projectId });
await dbContext.SaveChangesAsync();
Expand Down
2 changes: 1 addition & 1 deletion frontend/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ type UsersCollectionSegment {
totalCount: Int!
}

union AcquireProjectError = DbError | NotFoundError | AlreadyExistsError
union AcquireProjectError = DbError | NotFoundError

union AddProjectMemberError = NotFoundError | DbError | ProjectMembersMustBeVerified | ProjectMembersMustBeVerifiedForRole | ProjectMemberInvitedByEmail | InvalidEmailError | AlreadyExistsError

Expand Down

0 comments on commit f47d4df

Please sign in to comment.