Skip to content
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

feat(graphql): Create separate type for sub-parties #1510

Merged
merged 4 commits into from
Nov 22, 2024
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
14 changes: 13 additions & 1 deletion docs/schema/V1/schema.verified.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ type AttachmentUrl {
}

type AuthorizedParty {
subParties: [AuthorizedSubParty!]
party: String!
oskogstad marked this conversation as resolved.
Show resolved Hide resolved
name: String!
partyType: String!
isDeleted: Boolean!
hasKeyRole: Boolean!
isCurrentEndUser: Boolean!
isMainAdministrator: Boolean!
isAccessManager: Boolean!
hasOnlyAccessToSubParties: Boolean!
}

type AuthorizedSubParty {
party: String!
name: String!
partyType: String!
Expand All @@ -75,7 +88,6 @@ type AuthorizedParty {
isMainAdministrator: Boolean!
isAccessManager: Boolean!
hasOnlyAccessToSubParties: Boolean!
subParties: [AuthorizedParty!]
}

type Content {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ public sealed class MappingProfile : Profile
public MappingProfile()
{
CreateMap<AuthorizedPartyDto, AuthorizedParty>();
CreateMap<AuthorizedPartyDto, AuthorizedSubParty>();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Digdir.Domain.Dialogporten.GraphQL.EndUser.Parties;

public sealed class AuthorizedParty
public class AuthorizedPartyBase
{
public string Party { get; init; } = null!;
public string Name { get; init; } = null!;
Expand All @@ -11,5 +11,11 @@ public sealed class AuthorizedParty
public bool IsMainAdministrator { get; init; }
public bool IsAccessManager { get; init; }
public bool HasOnlyAccessToSubParties { get; init; }
public List<AuthorizedParty>? SubParties { get; init; }
}

public sealed class AuthorizedParty : AuthorizedPartyBase
{
public List<AuthorizedSubParty>? SubParties { get; init; }
}

public sealed class AuthorizedSubParty : AuthorizedPartyBase;
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Digdir.Domain.Dialogporten.Application.Externals;
using Digdir.Domain.Dialogporten.Application.Externals.AltinnAuthorization;
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities;
using Digdir.Domain.Dialogporten.Domain.Parties;
using Digdir.Domain.Dialogporten.Domain.Parties.Abstractions;
using Microsoft.EntityFrameworkCore;

Expand Down Expand Up @@ -53,7 +54,23 @@ public async Task<DialogSearchAuthorizationResult> GetAuthorizedResourcesForSear

[SuppressMessage("Performance", "CA1822:Mark members as static")]
public async Task<AuthorizedPartiesResult> GetAuthorizedParties(IPartyIdentifier authenticatedParty, bool _ = false, CancellationToken __ = default)
=> await Task.FromResult(new AuthorizedPartiesResult { AuthorizedParties = [new() { Name = "Local Party", Party = authenticatedParty.FullId, IsCurrentEndUser = true }] });
=> await Task.FromResult(new AuthorizedPartiesResult
{
AuthorizedParties = [new()
{
Name = "Local Party",
Party = authenticatedParty.FullId,
IsCurrentEndUser = true,
SubParties = [
new()
{
Name = "Local Sub Party",
Party = NorwegianOrganizationIdentifier.PrefixWithSeparator + "123456789",
IsCurrentEndUser = true
}
]
}]
});
oskogstad marked this conversation as resolved.
Show resolved Hide resolved

public Task<bool> HasListAuthorizationForDialog(DialogEntity dialog, CancellationToken cancellationToken) => Task.FromResult(true);
}
Loading