Address code review findings in relay fetch and iam
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -24,19 +24,19 @@ import {
|
|||||||
import { GraphQLError } from "graphql";
|
import { GraphQLError } from "graphql";
|
||||||
|
|
||||||
const hasUnauthenticatedError = (error: GraphQLError) =>
|
const hasUnauthenticatedError = (error: GraphQLError) =>
|
||||||
error.extensions?.code == "UNAUTHENTICATED";
|
error.extensions?.code === "UNAUTHENTICATED";
|
||||||
|
|
||||||
const hasFullNameRequiredError = (error: GraphQLError) =>
|
const hasFullNameRequiredError = (error: GraphQLError) =>
|
||||||
error.extensions?.code == "FULL_NAME_REQUIRED";
|
error.extensions?.code === "FULL_NAME_REQUIRED";
|
||||||
|
|
||||||
const hasAssumptionRequiredError = (error: GraphQLError) =>
|
const hasAssumptionRequiredError = (error: GraphQLError) =>
|
||||||
error.extensions?.code == "ASSUMPTION_REQUIRED";
|
error.extensions?.code === "ASSUMPTION_REQUIRED";
|
||||||
|
|
||||||
const hasNDASignatureRequiredError = (error: GraphQLError) =>
|
const hasNDASignatureRequiredError = (error: GraphQLError) =>
|
||||||
error.extensions?.code == "NDA_SIGNATURE_REQUIRED";
|
error.extensions?.code === "NDA_SIGNATURE_REQUIRED";
|
||||||
|
|
||||||
const hasForbiddenError = (error: GraphQLError) =>
|
const hasForbiddenError = (error: GraphQLError) =>
|
||||||
error.extensions?.code == "FORBIDDEN";
|
error.extensions?.code === "FORBIDDEN";
|
||||||
|
|
||||||
export const makeFetchQuery = (endpoint: string): FetchFunction => {
|
export const makeFetchQuery = (endpoint: string): FetchFunction => {
|
||||||
return async (request, variables, _, uploadables) => {
|
return async (request, variables, _, uploadables) => {
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ func NewOrganizationService(svc *Service) *OrganizationService {
|
|||||||
return &OrganizationService{Service: svc}
|
return &OrganizationService{Service: svc}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *OrganizationService) UpdateMempership(
|
func (s *OrganizationService) UpdateMembership(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
organizationID gid.GID,
|
organizationID gid.GID,
|
||||||
membershipID gid.GID,
|
membershipID gid.GID,
|
||||||
@@ -797,10 +797,6 @@ func (s *OrganizationService) UpdateOrganization(ctx context.Context, organizati
|
|||||||
organization.Name = *req.Name
|
organization.Name = *req.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Name != nil {
|
|
||||||
organization.Name = *req.Name
|
|
||||||
}
|
|
||||||
|
|
||||||
if req.Description != nil {
|
if req.Description != nil {
|
||||||
organization.Description = *req.Description
|
organization.Description = *req.Description
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ func (r *mutationResolver) UpdateMembership(ctx context.Context, input types.Upd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
membership, err := r.iam.OrganizationService.UpdateMempership(ctx, input.OrganizationID, input.MembershipID, input.Role)
|
membership, err := r.iam.OrganizationService.UpdateMembership(ctx, input.OrganizationID, input.MembershipID, input.Role)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.logger.ErrorCtx(ctx, "cannot update membership", log.Error(err))
|
r.logger.ErrorCtx(ctx, "cannot update membership", log.Error(err))
|
||||||
return nil, gqlutils.Internal(ctx)
|
return nil, gqlutils.Internal(ctx)
|
||||||
|
|||||||
@@ -2494,7 +2494,7 @@ func (r *Resolver) UpdateMembershipTool(ctx context.Context, req *mcp.CallToolRe
|
|||||||
r.MustAuthorize(ctx, input.MembershipID, iam.ActionMembershipRoleSetOwner)
|
r.MustAuthorize(ctx, input.MembershipID, iam.ActionMembershipRoleSetOwner)
|
||||||
}
|
}
|
||||||
|
|
||||||
membership, err := r.iamSvc.OrganizationService.UpdateMempership(ctx, input.OrganizationID, input.MembershipID, input.Role)
|
membership, err := r.iamSvc.OrganizationService.UpdateMembership(ctx, input.OrganizationID, input.MembershipID, input.Role)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, types.UpdateMembershipOutput{}, fmt.Errorf("update membership: %w", err)
|
return nil, types.UpdateMembershipOutput{}, fmt.Errorf("update membership: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user