-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into vsezima/cors-exposed-headers
- Loading branch information
Showing
6 changed files
with
102 additions
and
57 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
23 changes: 0 additions & 23 deletions
23
src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Extensions/FieldTypeExtensions.cs
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Extensions/GraphQLTypeExtensions.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,40 @@ | ||
using System; | ||
using System.Linq; | ||
using GraphQL.Types; | ||
|
||
namespace OrchardCore.ContentManagement.GraphQL; | ||
|
||
public static class GraphQLTypeExtensions | ||
{ | ||
public static FieldType WithPartCollapsedMetaData(this FieldType fieldType, bool collapsed = true) | ||
=> fieldType.WithMetaData("PartCollapsed", collapsed); | ||
|
||
public static FieldType WithPartNameMetaData(this FieldType fieldType, string partName) | ||
=> fieldType.WithMetaData("PartName", partName); | ||
|
||
/// <summary> | ||
/// Checks if the field exists in the GraphQL type in a case-insensitive way. | ||
/// </summary> | ||
/// <remarks> | ||
/// <para> | ||
/// This is the same as calling <see cref="IComplexGraphType.HasField(string)"/> but in a case-insensitive way. OC | ||
/// fields may be added with different casings, and we want to avoid collisions even then. | ||
/// </para> | ||
/// <para> | ||
/// See <see href="https://github.com/OrchardCMS/OrchardCore/pull/16151"/> and its corresponding issues for context. | ||
/// </para> | ||
/// </remarks> | ||
public static bool HasFieldIgnoreCase(this IComplexGraphType graphType, string fieldName) | ||
=> graphType.Fields.Any(field => field.Name.Equals(fieldName, StringComparison.OrdinalIgnoreCase)); | ||
|
||
private static FieldType WithMetaData(this FieldType fieldType, string name, object value) | ||
{ | ||
// TODO: Understand if locking is the best solution to https://github.com/OrchardCMS/OrchardCore/issues/15308 | ||
lock (fieldType.Metadata) | ||
{ | ||
fieldType.Metadata.TryAdd(name, value); | ||
} | ||
|
||
return fieldType; | ||
} | ||
} |
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