-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update permission description via grapql (#1594)
* Mutation for permission * update permission2 * Update permission via graphql * Update schema --------- Co-authored-by: Bjørn Hoffmann <ManBearTM@users.noreply.github.com> Co-authored-by: Bjørn Hoffmann <bjorn.id@bhoffmann.com>
- Loading branch information
1 parent
afa1623
commit 67b7d5e
Showing
6 changed files
with
103 additions
and
5 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
apps/dh/api-dh/source/DataHub.WebApi/GraphQL/GraphQLMutation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2020 Energinet DataHub A/S | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License2"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
using Energinet.DataHub.MarketParticipant.Client; | ||
using Energinet.DataHub.MarketParticipant.Client.Models; | ||
using GraphQL; | ||
using GraphQL.MicrosoftDI; | ||
using GraphQL.Types; | ||
|
||
namespace Energinet.DataHub.WebApi.GraphQL | ||
{ | ||
public class GraphQLMutation : ObjectGraphType | ||
{ | ||
public GraphQLMutation() | ||
{ | ||
Field<NonNullGraphType<PermissionDtoType>>("permission") | ||
.Argument<NonNullGraphType<UpdatePermissionInputType>>("permission", "Permission to update") | ||
.Resolve() | ||
.WithScope() | ||
.WithService<IMarketParticipantPermissionsClient>() | ||
.ResolveAsync(async (context, client) => | ||
{ | ||
var updatePermissionDto = context.GetArgument<UpdatePermissionDto>("permission"); | ||
await client.UpdatePermissionAsync(updatePermissionDto); | ||
return await client.GetPermissionAsync(updatePermissionDto.Id); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
apps/dh/api-dh/source/DataHub.WebApi/GraphQL/Types/UpdatePermissionInputType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2020 Energinet DataHub A/S | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License2"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using Energinet.DataHub.MarketParticipant.Client.Models; | ||
using GraphQL.Types; | ||
|
||
namespace Energinet.DataHub.WebApi.GraphQL | ||
{ | ||
public class UpdatePermissionInputType : InputObjectGraphType<UpdatePermissionDto> | ||
{ | ||
public UpdatePermissionInputType() | ||
{ | ||
Name = "UpdatePermissionInput"; | ||
Field(x => x.Id).Description("The id of the permission to update"); | ||
Field(x => x.Description).Description("The description of the permission to update"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters