Skip to content

Commit

Permalink
chore: Log application result in graphql resolver (#1524)
Browse files Browse the repository at this point in the history
Co-authored-by: Knut Haug <knut.espen.haug@digdir.no>
Co-authored-by: Magnus Sandgren <5285192+MagnusSandgren@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 25, 2024
1 parent 83e704f commit 17abb10
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using AutoMapper;
using Digdir.Domain.Dialogporten.Application.Common.Extensions;
using Digdir.Domain.Dialogporten.Application.Externals.Presentation;
using Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.Parties.Queries.Get;
using Digdir.Domain.Dialogporten.GraphQL.EndUser.Parties;
using MediatR;
Expand All @@ -10,11 +12,17 @@ public partial class Queries
public async Task<List<AuthorizedParty>> GetParties(
[Service] ISender mediator,
[Service] IMapper mapper,
[Service] ILogger<Queries> logger,
[Service] IUser user,
CancellationToken cancellationToken)
{
var request = new GetPartiesQuery();
var result = await mediator.Send(request, cancellationToken);

user.GetPrincipal().TryGetPid(out var pid);
logger.LogInformation("GraphQL handler, app result for party {Party}: {@Result}",
pid, result);

return mapper.Map<List<AuthorizedParty>>(result.AuthorizedParties);
}
}
10 changes: 9 additions & 1 deletion src/Digdir.Domain.Dialogporten.GraphQL/appsettings.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,13 @@
}
]
}
}
},
"Serilog": {
"MinimumLevel": {
"Override": {
"Digdir.Domain.Dialogporten.Infrastructure.Altinn.Authorization.AltinnAuthorizationClient": "Information",
"Digdir.Domain.Dialogporten.GraphQL.EndUser.Queries": "Information"
}
}
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public async Task<AuthorizedPartiesResult> GetAuthorizedParties(IPartyIdentifier
=> await PerformAuthorizedPartiesRequest(authorizedPartiesRequest, token), token: cancellationToken);

// Temporary logging to debug missing authorized sub parties
_logger.LogInformation("Authorized parties for {Party}: {AuthorizedParties}", authenticatedParty, JsonSerializer.Serialize(authorizedParties, SerializerOptions));
_logger.LogInformation("Authorized parties for {Party}: {@AuthorizedParties}", authenticatedParty, authorizedParties);

return flatten ? GetFlattenedAuthorizedParties(authorizedParties) : authorizedParties;
}
Expand Down
9 changes: 1 addition & 8 deletions src/Digdir.Domain.Dialogporten.WebApi/appsettings.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,5 @@
}
]
}
},
"Serilog": {
"MinimumLevel": {
"Override": {
"Digdir.Domain.Dialogporten.Infrastructure.Altinn.Authorization": "Information"
}
}
},
}
}

0 comments on commit 17abb10

Please sign in to comment.