8000 feat(graphql): add bulk set system labels mutation by elsand · Pull Request #2333 · Altinn/dialogporten · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(graphql): add bulk set system labels mutation #2333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions docs/schema/V1/schema.verified.graphql
10000
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
subscription: Subscriptions
}

interface BulkSetSystemLabelError {
message: String!
}

interface DialogByIdError {
message: String!
}
Expand Down Expand Up @@ -92,6 +96,27 @@ type AuthorizedSubParty {
isAccessManager: Boolean!
}

type BulkSetSystemLabelConcurrencyError implements BulkSetSystemLabelError {
message: String!
}

type BulkSetSystemLabelDomainError implements BulkSetSystemLabelError {
message: String!
}

type BulkSetSystemLabelForbidden implements BulkSetSystemLabelError {
message: String!
}

type BulkSetSystemLabelPayload {
success: Boolean!
errors: [BulkSetSystemLabelError!]!
}

type BulkSetSystemLabelValidationError implements BulkSetSystemLabelError {
message: String!
}

type Content {
title: ContentValue!
summary: ContentValue!
Expand Down Expand Up @@ -183,6 +208,7 @@ type Localization {

type Mutations {
setSystemLabel(input: SetSystemLabelInput!): SetSystemLabelPayload!
bulkSetSystemLabels(input: BulkSetSystemLabelInput!): BulkSetSystemLabelPayload!
}

type Queries @authorize(policy: "enduser") {
Expand Down Expand Up @@ -293,6 +319,16 @@ type TransmissionContent {
contentReference: ContentValue
}

input BulkSetSystemLabelInput {
dialogs: [DialogRevisionInput!]!
systemLabels: [SystemLabel!]!
}

input DialogRevisionInput {
dialogId: UUID!
enduserContextRevision: UUID
}

input SearchDialogInput {
"Filter by one or more service owner codes"
org: [String!]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using AutoMapper;
using Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.DialogSystemLabels.Commands.Set;
using Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.DialogSystemLabels.Commands.BulkSet;
using Digdir.Domain.Dialogporten.Application.Features.V1.Common.SystemLabels;

namespace Digdir.Domain.Dialogporten.GraphQL.EndUser.MutationTypes;

Expand All @@ -9,5 +11,12 @@ public MappingProfile()
{
CreateMap<SetSystemLabelInput, SetSystemLabelCommand>()
.ForMember(dest => dest.SystemLabels, opt => opt.MapFrom(src => src.SystemLabels));

CreateMap<DialogRevisionInput, DialogRevisionDto>();

CreateMap<BulkSetSystemLabelInput, BulkSetSystemLabelDto>();

CreateMap<BulkSetSystemLabelInput, BulkSetSystemLabelCommand>()
.ForMember(dest => dest.Dto, opt => opt.MapFrom(src => src));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using AutoMapper;
using Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.DialogSystemLabels.Commands.Set;
using Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.DialogSystemLabels.Commands.BulkSet;
using Digdir.Domain.Dialogporten.GraphQL.Common;
using MediatR;

Expand Down Expand Up @@ -46,4 +47,35 @@ public async Task<SetSystemLabelPayload> SetSystemLabel(
},
concurrencyError => new SetSystemLabelPayload { Errors = [] });
}

public async Task<BulkSetSystemLabelPayload> BulkSetSystemLabels(
[Service] ISender mediator,
[Service] IMapper mapper,
BulkSetSystemLabelInput input)
{
var command = mapper.Map<BulkSetSystemLabelCommand>(input);
var result = await mediator.Send(command);

return result.Match(
_ => new BulkSetSystemLabelPayload { Success = true },
forbidden => new BulkSetSystemLabelPayload
{
Errors = [new BulkSetSystemLabelForbidden { Message = string.Join("; ", forbidden.Reasons) }]
},
domainError => new BulkSetSystemLabelPayload
{
Errors = domainError.Errors
.Select(x => new BulkSetSystemLabelDomainError { Message = x.ErrorMessage })
.Cast<IBulkSetSystemLabelError>()
.ToList()
},
validationError => new BulkSetSystemLabelPayload
{
Errors = validationError.Errors
.Select(x => new BulkSetSystemLabelValidationError { Message = x.ErrorMessage })
.Cast<IBulkSetSystemLabelError>()
.ToList()
},
concurrencyError => new BulkSetSystemLabelPayload { Errors = [] });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,47 @@ public sealed class SetSystemLabelValidationError : ISetSystemLabelError
{
public string Message { get; set; } = null!;
}

public sealed class BulkSetSystemLabelInput
{
public List<DialogRevisionInput> Dialogs { get; set; } = [];
public List<SystemLabel> SystemLabels { get; set; } = [];
}

public sealed class DialogRevisionInput
{
public Guid DialogId { get; set; }
public Guid? EnduserContextRevision { get; set; }
}

public sealed class BulkSetSystemLabelPayload
{
public bool Success { get; set; }
public List<IBulkSetSystemLabelError> Errors { get; set; } = [];
}

[InterfaceType("BulkSetSystemLabelError")]
public interface IBulkSetSystemLabelError
{
string Message { get; set; }
}

public sealed class BulkSetSystemLabelForbidden : IBulkSetSystemLabelError
{
public string Message { get; set; } = null!;
}

public sealed class BulkSetSystemLabelDomainError : IBulkSetSystemLabelError
{
public string Message { get; set; } = null!;
}

public sealed class BulkSetSystemLabelValidationError : IBulkSetSystemLabelError
{
public string Message { get; set; } = null!;
}

public sealed class BulkSetSystemLabelConcurrencyError : IBulkSetSystemLabelError
{
public string Message { get; set; } = null!;
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public static IServiceCollection AddDialogportenGraphQl(this IServiceCollection
.AddType<SearchDialogValidationError>()
.AddType<SearchDialogForbidden>()
.AddType<SetSystemLabelEntityNotFound>()
.AddType<BulkSetSystemLabelForbidden>()
.AddType<BulkSetSystemLabelDomainError>()
.AddType<BulkSetSystemLabelValidationError>()
.AddType<BulkSetSystemLabelConcurrencyError>()
.AddType<SearchDialogOrderByParsingError>()
.AddType<SearchDialogContinuationTokenParsingError>()
.AddMaxExecutionDepthRule(12)
Expand Down
0