-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
234 additions
and
23 deletions.
There are no files selected for viewing
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
48 changes: 48 additions & 0 deletions
48
...ir.Domain.Dialogporten.GraphQL/Common/Extensions/HotChocolate/DefinitionNodeExtensions.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,48 @@ | ||
using HotChocolate.Language; | ||
|
||
namespace Digdir.Domain.Dialogporten.GraphQL.Common.Extensions.HotChocolate; | ||
|
||
public static class DefinitionNodeExtensions | ||
{ | ||
public static bool TryGetSubscriptionDialogId(this IReadOnlyList<IDefinitionNode> definitions, out Guid dialogId) | ||
{ | ||
dialogId = Guid.Empty; | ||
|
||
foreach (var definition in definitions) | ||
{ | ||
if (definition is not OperationDefinitionNode operationDefinition) | ||
{ | ||
continue; | ||
} | ||
|
||
if (operationDefinition.Operation != OperationType.Subscription) | ||
{ | ||
continue; | ||
} | ||
|
||
if (operationDefinition.SelectionSet.Selections[0] is not FieldNode fieldNode) | ||
{ | ||
continue; | ||
} | ||
|
||
var dialogIdArgument = fieldNode.Arguments.SingleOrDefault(x => x.Name.Value == "dialogId"); | ||
|
||
if (dialogIdArgument is null) | ||
{ | ||
continue; | ||
} | ||
|
||
if (dialogIdArgument.Value.Value is null) | ||
{ | ||
continue; | ||
} | ||
|
||
if (Guid.TryParse(dialogIdArgument.Value.Value.ToString(), out dialogId)) | ||
{ | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} |
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
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