diff --git a/Directory.Packages.props b/Directory.Packages.props
index f807e47d456..869058edc6f 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -1,12 +1,15 @@
+
true
true
+
2.3.0
+
@@ -22,10 +25,10 @@
-
-
-
-
+
+
+
+
@@ -88,6 +91,7 @@
+
@@ -96,6 +100,7 @@
+
+
+
+
diff --git a/mkdocs.yml b/mkdocs.yml
index b4568757aa9..43ff7083b28 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -55,7 +55,8 @@ validation:
# Add files here that are intentionally not in the navigation and thus omitted_files shouldn't warn about them.
not_in_nav: |
samples/
-
+ releases/3.0.0.md
+
# Extensions
markdown_extensions:
- markdown.extensions.admonition
diff --git a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/GraphQLMiddleware.cs b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/GraphQLMiddleware.cs
index 60bdace4489..3f4ab760043 100644
--- a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/GraphQLMiddleware.cs
+++ b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/GraphQLMiddleware.cs
@@ -151,13 +151,13 @@ private async Task ExecuteAsync(HttpContext context)
options.Variables = request.Variables;
options.UserContext = _settings.BuildUserContext?.Invoke(context);
options.ValidationRules = DocumentValidator.CoreRules
- .Concat(context.RequestServices.GetServices())
- .Append(new ComplexityValidationRule(new ComplexityConfiguration
- {
- MaxDepth = _settings.MaxDepth,
- MaxComplexity = _settings.MaxComplexity,
- FieldImpact = _settings.FieldImpact
- }));
+ .Concat(context.RequestServices.GetServices())
+ .Append(new ComplexityValidationRule(new ComplexityOptions
+ {
+ MaxDepth = _settings.MaxDepth,
+ MaxComplexity = _settings.MaxComplexity,
+ DefaultObjectImpact = _settings.FieldImpact ?? 0,
+ }));
options.Listeners.Add(dataLoaderDocumentListener);
options.RequestServices = context.RequestServices;
});
diff --git a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Services/SchemaService.cs b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Services/SchemaService.cs
index 3b8f0e9c8b0..bc13d9055f5 100644
--- a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Services/SchemaService.cs
+++ b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Services/SchemaService.cs
@@ -1,4 +1,5 @@
using System.Collections.Concurrent;
+using GraphQL;
using GraphQL.MicrosoftDI;
using GraphQL.Types;
using Microsoft.Extensions.DependencyInjection;
@@ -6,7 +7,7 @@
namespace OrchardCore.Apis.GraphQL.Services;
-public class SchemaService : ISchemaFactory
+public sealed class SchemaService : ISchemaFactory
{
private readonly IEnumerable _schemaBuilders;
private readonly IServiceProvider _serviceProvider;
@@ -15,7 +16,9 @@ public class SchemaService : ISchemaFactory
private ISchema _schema;
- public SchemaService(IEnumerable schemaBuilders, IServiceProvider serviceProvider)
+ public SchemaService(
+ IEnumerable schemaBuilders,
+ IServiceProvider serviceProvider)
{
_schemaBuilders = schemaBuilders;
_serviceProvider = serviceProvider;
@@ -61,21 +64,23 @@ public async Task GetSchemaAsync()
var schema = new Schema(new SelfActivatingServiceProvider(_serviceProvider))
{
- Query = new ObjectGraphType { Name = "Query" },
- Mutation = new ObjectGraphType { Name = "Mutation" },
- Subscription = new ObjectGraphType { Name = "Subscription" },
+ Query = new ObjectGraphType
+ {
+ Name = "Query",
+ },
+ Mutation = new ObjectGraphType
+ {
+ Name = "Mutation",
+ },
+ Subscription = new ObjectGraphType
+ {
+ Name = "Subscription",
+ },
NameConverter = new OrchardFieldNameConverter(),
};
- foreach (var type in serviceProvider.GetServices())
- {
- schema.RegisterType(type);
- }
-
- foreach (var type in serviceProvider.GetServices())
- {
- schema.RegisterType(type);
- }
+ schema.RegisterTypes(serviceProvider.GetServices().ToArray());
+ schema.RegisterTypes(serviceProvider.GetServices().ToArray());
foreach (var builder in _schemaBuilders)
{
@@ -90,7 +95,6 @@ public async Task GetSchemaAsync()
await builder.BuildAsync(schema);
}
-
// Clean Query, Mutation and Subscription if they have no fields
// to prevent GraphQL configuration errors.
@@ -110,6 +114,7 @@ public async Task GetSchemaAsync()
}
schema.Initialize();
+
return _schema = schema;
}
finally
diff --git a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/ValidationRules/MaxNumberOfResultsValidationRule.cs b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/ValidationRules/MaxNumberOfResultsValidationRule.cs
index c4df8595dfc..622a252bf38 100644
--- a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/ValidationRules/MaxNumberOfResultsValidationRule.cs
+++ b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/ValidationRules/MaxNumberOfResultsValidationRule.cs
@@ -25,7 +25,7 @@ public MaxNumberOfResultsValidationRule(
_logger = logger;
}
- public ValueTask ValidateAsync(ValidationContext validationContext)
+ public ValueTask GetPreNodeVisitorAsync(ValidationContext validationContext)
{
return ValueTask.FromResult((INodeVisitor)new NodeVisitors(
new MatchingNodeVisitor((arg, visitorContext) =>
@@ -68,4 +68,10 @@ public ValueTask ValidateAsync(ValidationContext validationContext
}
})));
}
+
+ public ValueTask GetVariableVisitorAsync(ValidationContext context)
+ => ValueTask.FromResult(null);
+
+ public ValueTask GetPostNodeVisitorAsync(ValidationContext context)
+ => ValueTask.FromResult(null);
}
diff --git a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/ValidationRules/RequiresPermissionValidationRule.cs b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/ValidationRules/RequiresPermissionValidationRule.cs
index ba3183d2447..d1c061f9e70 100644
--- a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/ValidationRules/RequiresPermissionValidationRule.cs
+++ b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/ValidationRules/RequiresPermissionValidationRule.cs
@@ -23,7 +23,7 @@ public RequiresPermissionValidationRule(
S = localizer;
}
- public async ValueTask ValidateAsync(ValidationContext validationContext)
+ public async ValueTask GetPreNodeVisitorAsync(ValidationContext validationContext)
{
// shouldn't we access UserContext from validation-context inside MatchingNodeVisitor actions?
var userContext = (GraphQLUserContext)validationContext.UserContext;
@@ -121,4 +121,10 @@ private void AddPermissionValidationError(ValidationContext validationContext, A
S["Authorization is required to access the node. {0}", nodeName],
node));
}
+
+ public ValueTask GetVariableVisitorAsync(ValidationContext context)
+ => ValueTask.FromResult(null);
+
+ public ValueTask GetPostNodeVisitorAsync(ValidationContext context)
+ => ValueTask.FromResult(null);
}
diff --git a/src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Fields/ContentFieldsProvider.cs b/src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Fields/ContentFieldsProvider.cs
index 57da8bc0e8b..6954860e83b 100644
--- a/src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Fields/ContentFieldsProvider.cs
+++ b/src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Fields/ContentFieldsProvider.cs
@@ -20,10 +20,11 @@ public class ContentFieldsProvider : IContentFieldProvider
{
Description = "Boolean field",
FieldType = typeof(BooleanGraphType),
+ ResolvedType = new BooleanGraphType(),
UnderlyingType = typeof(BooleanField),
FieldAccessor = field => ((BooleanField)field).Value,
IndexType = typeof(BooleanFieldIndex),
- Index = nameof(BooleanFieldIndex.Boolean)
+ Index = nameof(BooleanFieldIndex.Boolean),
}
},
{
@@ -32,10 +33,11 @@ public class ContentFieldsProvider : IContentFieldProvider
{
Description = "Date field",
FieldType = typeof(DateGraphType),
+ ResolvedType = new DateGraphType(),
UnderlyingType = typeof(DateField),
FieldAccessor = field => ((DateField)field).Value,
IndexType = typeof(DateFieldIndex),
- Index = nameof(DateFieldIndex.Date)
+ Index = nameof(DateFieldIndex.Date),
}
},
{
@@ -44,10 +46,11 @@ public class ContentFieldsProvider : IContentFieldProvider
{
Description = "Date & time field",
FieldType = typeof(DateTimeGraphType),
+ ResolvedType = new DateTimeGraphType(),
UnderlyingType = typeof(DateTimeField),
FieldAccessor = field => ((DateTimeField)field).Value,
IndexType = typeof(DateTimeFieldIndex),
- Index = nameof(DateTimeFieldIndex.DateTime)
+ Index = nameof(DateTimeFieldIndex.DateTime),
}
},
{
@@ -56,6 +59,7 @@ public class ContentFieldsProvider : IContentFieldProvider
{
Description = "Numeric field",
FieldType = typeof(DecimalGraphType),
+ ResolvedType = new DecimalGraphType(),
UnderlyingType = typeof(NumericField),
FieldAccessor = field => ((NumericField)field).Value,
IndexType = typeof(NumericFieldIndex),
@@ -68,6 +72,7 @@ public class ContentFieldsProvider : IContentFieldProvider
{
Description = "Text field",
FieldType = typeof(StringGraphType),
+ ResolvedType = new StringGraphType(),
UnderlyingType = typeof(TextField),
FieldAccessor = field => ((TextField)field).Text,
IndexType = typeof(TextFieldIndex),
@@ -80,6 +85,7 @@ public class ContentFieldsProvider : IContentFieldProvider
{
Description = "Time field",
FieldType = typeof(TimeSpanGraphType),
+ ResolvedType = new TimeSpanGraphType(),
UnderlyingType = typeof(TimeField),
FieldAccessor = field => ((TimeField)field).Value,
IndexType = typeof(TimeFieldIndex),
@@ -92,6 +98,7 @@ public class ContentFieldsProvider : IContentFieldProvider
{
Description = "Multi text field",
FieldType = typeof(ListGraphType),
+ ResolvedType = new ListGraphType(new StringGraphType()),
UnderlyingType = typeof(MultiTextField),
FieldAccessor = field => ((MultiTextField)field).Values,
}
@@ -107,9 +114,10 @@ public FieldType GetField(ISchema schema, ContentPartFieldDefinition field, stri
return new FieldType
{
- Name = customFieldName ?? field.Name,
+ Name = customFieldName ?? schema.NameConverter.NameForField(field.Name, null),
Description = fieldDescriptor.Description,
Type = fieldDescriptor.FieldType,
+ ResolvedType = fieldDescriptor.ResolvedType,
Resolver = new FuncFieldResolver(context =>
{
// Check if part has been collapsed by trying to get the parent part.
@@ -127,7 +135,8 @@ public FieldType GetField(ISchema schema, ContentPartFieldDefinition field, stri
};
}
- public bool HasField(ISchema schema, ContentPartFieldDefinition field) => _contentFieldTypeMappings.ContainsKey(field.FieldDefinition.Name);
+ public bool HasField(ISchema schema, ContentPartFieldDefinition field)
+ => _contentFieldTypeMappings.ContainsKey(field.FieldDefinition.Name);
public FieldTypeIndexDescriptor GetFieldIndex(ContentPartFieldDefinition field)
{
@@ -141,22 +150,29 @@ public FieldTypeIndexDescriptor GetFieldIndex(ContentPartFieldDefinition field)
return new FieldTypeIndexDescriptor
{
Index = fieldDescriptor.Index,
- IndexType = fieldDescriptor.IndexType
+ IndexType = fieldDescriptor.IndexType,
};
}
- public bool HasFieldIndex(ContentPartFieldDefinition field) =>
- _contentFieldTypeMappings.TryGetValue(field.FieldDefinition.Name, out var fieldTypeDescriptor) &&
+ public bool HasFieldIndex(ContentPartFieldDefinition field)
+ => _contentFieldTypeMappings.TryGetValue(field.FieldDefinition.Name, out var fieldTypeDescriptor) &&
fieldTypeDescriptor.IndexType != null &&
!string.IsNullOrWhiteSpace(fieldTypeDescriptor.Index);
private sealed class FieldTypeDescriptor
{
public string Description { get; set; }
+
public Type FieldType { get; set; }
+
public Type UnderlyingType { get; set; }
+
+ public required IGraphType ResolvedType { get; set; }
+
public Func FieldAccessor { get; set; }
+
public string Index { get; set; }
+
public Type IndexType { get; set; }
}
}
diff --git a/src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Types/ContentPickerFieldQueryObjectType.cs b/src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Types/ContentPickerFieldQueryObjectType.cs
index af2371a288a..df80bd7e94f 100644
--- a/src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Types/ContentPickerFieldQueryObjectType.cs
+++ b/src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Types/ContentPickerFieldQueryObjectType.cs
@@ -1,4 +1,4 @@
-using GraphQL.DataLoader;
+using GraphQL;
using GraphQL.Types;
using OrchardCore.Apis.GraphQL;
using OrchardCore.ContentFields.Fields;
@@ -29,7 +29,7 @@ public ContentPickerFieldQueryObjectType()
{
var contentItemLoader = x.GetOrAddPublishedContentItemByIdDataLoader();
- return (contentItemLoader.LoadAsync(x.Page(x.Source.ContentItemIds))).Then(itemResultSet =>
+ return contentItemLoader.LoadAsync(x.Page(x.Source.ContentItemIds)).Then(itemResultSet =>
{
return itemResultSet.SelectMany(x => x);
});
diff --git a/src/OrchardCore.Modules/OrchardCore.Flows/GraphQL/FlowMetadataContentTypeBuilder.cs b/src/OrchardCore.Modules/OrchardCore.Flows/GraphQL/FlowMetadataContentTypeBuilder.cs
index 25119a26ccc..f3414b3d8a5 100644
--- a/src/OrchardCore.Modules/OrchardCore.Flows/GraphQL/FlowMetadataContentTypeBuilder.cs
+++ b/src/OrchardCore.Modules/OrchardCore.Flows/GraphQL/FlowMetadataContentTypeBuilder.cs
@@ -18,4 +18,8 @@ public void Build(ISchema schema, FieldType contentQuery, ContentTypeDefinition
contentItemType.Field("metadata")
.Resolve(context => context.Source.As());
}
+
+ public void Clear()
+ {
+ }
}
diff --git a/src/OrchardCore.Modules/OrchardCore.Layers/GraphQL/LayerQueryObjectType.cs b/src/OrchardCore.Modules/OrchardCore.Layers/GraphQL/LayerQueryObjectType.cs
index a12f83eecda..58593fcf4e4 100644
--- a/src/OrchardCore.Modules/OrchardCore.Layers/GraphQL/LayerQueryObjectType.cs
+++ b/src/OrchardCore.Modules/OrchardCore.Layers/GraphQL/LayerQueryObjectType.cs
@@ -18,11 +18,16 @@ public LayerQueryObjectType()
{
Name = "Layer";
- Field(layer => layer.Name).Description("The name of the layer.");
+ Field(layer => layer.Name)
+ .Description("The name of the layer.");
+
Field, IEnumerable>("layerrule")
.Description("The rule that activates the layer.")
.Resolve(ctx => ctx.Source.LayerRule.Conditions);
- Field(layer => layer.Description).Description("The description of the layer.");
+
+ Field(layer => layer.Description)
+ .Description("The description of the layer.");
+
Field, IEnumerable>("widgets")
.Description("The widgets for this layer.")
.Argument("status", "publication status of the widgets")
@@ -50,8 +55,8 @@ async ValueTask> GetWidgetsForLayerAsync(IResolveFieldC
}
}
- private static Expression> GetVersionFilter(PublicationStatusEnum status) =>
- status switch
+ private static Expression> GetVersionFilter(PublicationStatusEnum status)
+ => status switch
{
PublicationStatusEnum.Published => x => x.Published,
PublicationStatusEnum.Draft => x => x.Latest && !x.Published,
diff --git a/src/OrchardCore.Modules/OrchardCore.Layers/GraphQL/SiteLayersQuery.cs b/src/OrchardCore.Modules/OrchardCore.Layers/GraphQL/SiteLayersQuery.cs
index 1421bb17dc2..1e4e60cdd45 100644
--- a/src/OrchardCore.Modules/OrchardCore.Layers/GraphQL/SiteLayersQuery.cs
+++ b/src/OrchardCore.Modules/OrchardCore.Layers/GraphQL/SiteLayersQuery.cs
@@ -11,20 +11,22 @@
namespace OrchardCore.Layers.GraphQL;
-public class SiteLayersQuery : ISchemaBuilder
+public sealed class SiteLayersQuery : ISchemaBuilder
{
- protected readonly IStringLocalizer S;
private readonly GraphQLContentOptions _graphQLContentOptions;
+ internal readonly IStringLocalizer S;
+
public SiteLayersQuery(
- IStringLocalizer localizer,
- IOptions graphQLContentOptions)
+ IOptions graphQLContentOptions,
+ IStringLocalizer localizer)
{
- S = localizer;
_graphQLContentOptions = graphQLContentOptions.Value;
+ S = localizer;
}
- public Task GetIdentifierAsync() => Task.FromResult(string.Empty);
+ public Task GetIdentifierAsync()
+ => Task.FromResult(string.Empty);
public Task BuildAsync(ISchema schema)
{
@@ -38,7 +40,7 @@ public Task BuildAsync(ISchema schema)
Name = "SiteLayers",
Description = S["Site layers define the rules and zone placement for widgets."],
Type = typeof(ListGraphType),
- Resolver = new LockedAsyncFieldResolver>(ResolveAsync)
+ Resolver = new LockedAsyncFieldResolver>(ResolveAsync),
};
schema.Query.AddField(field);
@@ -49,7 +51,9 @@ public Task BuildAsync(ISchema schema)
private async ValueTask> ResolveAsync(IResolveFieldContext resolveContext)
{
var layerService = resolveContext.RequestServices.GetService();
+
var allLayers = await layerService.GetLayersAsync();
+
return allLayers.Layers;
}
}
diff --git a/src/OrchardCore.Modules/OrchardCore.Localization/GraphQL/SiteCulturesQuery.cs b/src/OrchardCore.Modules/OrchardCore.Localization/GraphQL/SiteCulturesQuery.cs
index 1fb5ba5d14a..347eee587d7 100644
--- a/src/OrchardCore.Modules/OrchardCore.Localization/GraphQL/SiteCulturesQuery.cs
+++ b/src/OrchardCore.Modules/OrchardCore.Localization/GraphQL/SiteCulturesQuery.cs
@@ -12,11 +12,12 @@ namespace OrchardCore.Localization.GraphQL;
///
/// Represents a site cultures for Graph QL.
///
-public class SiteCulturesQuery : ISchemaBuilder
+public sealed class SiteCulturesQuery : ISchemaBuilder
{
- protected readonly IStringLocalizer S;
private readonly GraphQLContentOptions _graphQLContentOptions;
+ internal readonly IStringLocalizer S;
+
///
/// Creates a new instance of the .
///
@@ -31,7 +32,8 @@ public SiteCulturesQuery(
_graphQLContentOptions = graphQLContentOptions.Value;
}
- public Task GetIdentifierAsync() => Task.FromResult(string.Empty);
+ public Task GetIdentifierAsync()
+ => Task.FromResult(string.Empty);
///
public Task BuildAsync(ISchema schema)
@@ -46,7 +48,7 @@ public Task BuildAsync(ISchema schema)
Name = "SiteCultures",
Description = S["The active cultures configured for the site."],
Type = typeof(ListGraphType),
- Resolver = new LockedAsyncFieldResolver>(ResolveAsync)
+ Resolver = new LockedAsyncFieldResolver>(ResolveAsync),
};
schema.Query.AddField(field);
diff --git a/src/OrchardCore.Modules/OrchardCore.Media/GraphQL/MediaAssetQuery.cs b/src/OrchardCore.Modules/OrchardCore.Media/GraphQL/MediaAssetQuery.cs
index 71c98579da2..4bd5fdc9b7a 100644
--- a/src/OrchardCore.Modules/OrchardCore.Media/GraphQL/MediaAssetQuery.cs
+++ b/src/OrchardCore.Modules/OrchardCore.Media/GraphQL/MediaAssetQuery.cs
@@ -10,11 +10,12 @@
namespace OrchardCore.Media.GraphQL;
-public class MediaAssetQuery : ISchemaBuilder
+public sealed class MediaAssetQuery : ISchemaBuilder
{
- protected readonly IStringLocalizer S;
private readonly GraphQLContentOptions _graphQLContentOptions;
+ internal IStringLocalizer S;
+
public MediaAssetQuery(
IStringLocalizer localizer,
IOptions graphQLContentOptions)
diff --git a/src/OrchardCore.Modules/OrchardCore.Menu/GraphQL/MenuItemContentTypeBuilder.cs b/src/OrchardCore.Modules/OrchardCore.Menu/GraphQL/MenuItemContentTypeBuilder.cs
index 6c2a72c5fee..98dac63c2d9 100644
--- a/src/OrchardCore.Modules/OrchardCore.Menu/GraphQL/MenuItemContentTypeBuilder.cs
+++ b/src/OrchardCore.Modules/OrchardCore.Menu/GraphQL/MenuItemContentTypeBuilder.cs
@@ -1,4 +1,3 @@
-using GraphQL.Resolvers;
using GraphQL.Types;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.GraphQL.Queries.Types;
@@ -16,13 +15,14 @@ public void Build(ISchema schema, FieldType contentQuery, ContentTypeDefinition
return;
}
- contentItemType.AddField(new FieldType
- {
- Type = typeof(MenuItemsListQueryObjectType),
- Name = nameof(MenuItemsListPart).ToFieldName(),
- Resolver = new FuncFieldResolver(context => context.Source.As())
- });
+ contentItemType
+ .Field(nameof(MenuItemsListPart).ToFieldName())
+ .Resolve(context => context.Source.As());
contentItemType.Interface();
}
+
+ public void Clear()
+ {
+ }
}
diff --git a/src/OrchardCore.Modules/OrchardCore.Menu/GraphQL/MenuItemsListQueryObjectType.cs b/src/OrchardCore.Modules/OrchardCore.Menu/GraphQL/MenuItemsListQueryObjectType.cs
index 15627321436..2030c2c94ce 100644
--- a/src/OrchardCore.Modules/OrchardCore.Menu/GraphQL/MenuItemsListQueryObjectType.cs
+++ b/src/OrchardCore.Modules/OrchardCore.Menu/GraphQL/MenuItemsListQueryObjectType.cs
@@ -12,6 +12,5 @@ public MenuItemsListQueryObjectType()
Field>("menuItems")
.Description("The menu items.")
.Resolve(context => context.Source.MenuItems);
-
}
}
diff --git a/src/OrchardCore.Modules/OrchardCore.Queries/Sql/GraphQL/SqlQueryFieldTypeProvider.cs b/src/OrchardCore.Modules/OrchardCore.Queries/Sql/GraphQL/SqlQueryFieldTypeProvider.cs
index f0f7572fa78..98d9893d656 100644
--- a/src/OrchardCore.Modules/OrchardCore.Queries/Sql/GraphQL/SqlQueryFieldTypeProvider.cs
+++ b/src/OrchardCore.Modules/OrchardCore.Queries/Sql/GraphQL/SqlQueryFieldTypeProvider.cs
@@ -18,7 +18,7 @@ namespace OrchardCore.Queries.Sql.GraphQL.Queries;
/// This implementation of registers
/// all SQL Queries as GraphQL queries.
///
-public class SqlQueryFieldTypeProvider : ISchemaBuilder
+public sealed class SqlQueryFieldTypeProvider : ISchemaBuilder
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ILogger _logger;
@@ -100,7 +100,7 @@ private static FieldType BuildSchemaBasedFieldType(Query query, JsonNode querySc
var typeType = new ObjectGraphType
{
- Name = fieldTypeName
+ Name = fieldTypeName,
};
foreach (var child in properties)
@@ -131,8 +131,8 @@ private static FieldType BuildSchemaBasedFieldType(Query query, JsonNode querySc
var field = new FieldType()
{
Name = nameLower,
- Description = description,
Type = typeof(IntGraphType),
+ Description = description,
Resolver = new FuncFieldResolver(context =>
{
var source = context.Source;
diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/GraphQL/ElasticQueryFieldTypeProvider.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/GraphQL/ElasticQueryFieldTypeProvider.cs
index 492dcccb0e6..11440892e85 100644
--- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/GraphQL/ElasticQueryFieldTypeProvider.cs
+++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/GraphQL/ElasticQueryFieldTypeProvider.cs
@@ -16,12 +16,14 @@
namespace OrchardCore.Search.Elasticsearch.GraphQL.Queries;
-public class ElasticQueryFieldTypeProvider : ISchemaBuilder
+public sealed class ElasticQueryFieldTypeProvider : ISchemaBuilder
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ILogger _logger;
- public ElasticQueryFieldTypeProvider(IHttpContextAccessor httpContextAccessor, ILogger logger)
+ public ElasticQueryFieldTypeProvider(
+ IHttpContextAccessor httpContextAccessor,
+ ILogger logger)
{
_httpContextAccessor = httpContextAccessor;
_logger = logger;
@@ -112,6 +114,7 @@ private static FieldType BuildSchemaBasedFieldType(Query query, JsonNode querySc
Name = nameLower,
Description = description,
Type = typeof(StringGraphType),
+ ResolvedType = new StringGraphType(),
Resolver = new FuncFieldResolver(context =>
{
var source = context.Source;
@@ -128,6 +131,7 @@ private static FieldType BuildSchemaBasedFieldType(Query query, JsonNode querySc
Name = nameLower,
Description = description,
Type = typeof(IntGraphType),
+ ResolvedType = new IntGraphType(),
Resolver = new FuncFieldResolver(context =>
{
var source = context.Source;
diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/GraphQL/LuceneQueryFieldTypeProvider.cs b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/GraphQL/LuceneQueryFieldTypeProvider.cs
index 63b4e630c38..c7b5cb68591 100644
--- a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/GraphQL/LuceneQueryFieldTypeProvider.cs
+++ b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/GraphQL/LuceneQueryFieldTypeProvider.cs
@@ -15,7 +15,7 @@
namespace OrchardCore.Queries.Lucene.GraphQL.Queries;
-public class LuceneQueryFieldTypeProvider : ISchemaBuilder
+public sealed class LuceneQueryFieldTypeProvider : ISchemaBuilder
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ILogger _logger;
@@ -114,6 +114,7 @@ private static FieldType BuildSchemaBasedFieldType(Query query, JsonNode querySc
Name = nameLower,
Description = description,
Type = typeof(StringGraphType),
+ ResolvedType = new StringGraphType(),
Resolver = new FuncFieldResolver(context =>
{
var source = context.Source;
@@ -130,6 +131,7 @@ private static FieldType BuildSchemaBasedFieldType(Query query, JsonNode querySc
Name = nameLower,
Description = description,
Type = typeof(IntGraphType),
+ ResolvedType = new IntGraphType(),
Resolver = new FuncFieldResolver(context =>
{
var source = context.Source;
diff --git a/src/OrchardCore.Modules/OrchardCore.Users/GraphQL/CurrentUserQuery.cs b/src/OrchardCore.Modules/OrchardCore.Users/GraphQL/CurrentUserQuery.cs
index 5f108547a0d..b1198136f22 100644
--- a/src/OrchardCore.Modules/OrchardCore.Users/GraphQL/CurrentUserQuery.cs
+++ b/src/OrchardCore.Modules/OrchardCore.Users/GraphQL/CurrentUserQuery.cs
@@ -16,7 +16,8 @@ namespace OrchardCore.Users.GraphQL;
internal sealed class CurrentUserQuery : ISchemaBuilder
{
private readonly IHttpContextAccessor _httpContextAccessor;
- private readonly IStringLocalizer S;
+
+ internal readonly IStringLocalizer S;
public CurrentUserQuery(
IHttpContextAccessor httpContextAccessor,
@@ -50,6 +51,7 @@ public Task BuildAsync(ISchema schema)
public Task GetIdentifierAsync()
{
var contentDefinitionManager = _httpContextAccessor.HttpContext.RequestServices.GetRequiredService();
+
return contentDefinitionManager.GetIdentifierAsync();
}
}
diff --git a/src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/GraphQLFieldNameAttribute.cs b/src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/GraphQLFieldNameAttribute.cs
index ce557684395..5c457989358 100644
--- a/src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/GraphQLFieldNameAttribute.cs
+++ b/src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/GraphQLFieldNameAttribute.cs
@@ -10,5 +10,6 @@ public GraphQLFieldNameAttribute(string field, string mapped)
}
public string Field { get; }
+
public string Mapped { get; }
}
diff --git a/src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/GraphQLSettings.cs b/src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/GraphQLSettings.cs
index 69313c2b434..2a48c5b0586 100644
--- a/src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/GraphQLSettings.cs
+++ b/src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/GraphQLSettings.cs
@@ -5,15 +5,21 @@ namespace OrchardCore.Apis.GraphQL;
public class GraphQLSettings
{
public PathString Path { get; set; } = "/api/graphql";
+
public Func> BuildUserContext { get; set; }
public bool ExposeExceptions { get; set; }
public int? MaxDepth { get; set; }
+
public int? MaxComplexity { get; set; }
+
public double? FieldImpact { get; set; }
+
public int DefaultNumberOfResults { get; set; }
+
public int MaxNumberOfResults { get; set; }
+
public MaxNumberOfResultsValidationMode MaxNumberOfResultsValidationMode { get; set; }
}
@@ -21,5 +27,5 @@ public enum MaxNumberOfResultsValidationMode
{
Default,
Enabled,
- Disabled
+ Disabled,
}
diff --git a/src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/GraphQLUserContext.cs b/src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/GraphQLUserContext.cs
index 4816a009504..41e297c5e47 100644
--- a/src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/GraphQLUserContext.cs
+++ b/src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/GraphQLUserContext.cs
@@ -5,5 +5,6 @@ namespace OrchardCore.Apis.GraphQL;
public class GraphQLUserContext : Dictionary
{
public ClaimsPrincipal User { get; set; }
+
public SemaphoreSlim ExecutionContextLock { get; } = new SemaphoreSlim(1, 1);
}
diff --git a/src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/Queries/IFilterInputObjectGraphType.cs b/src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/Queries/IFilterInputObjectGraphType.cs
new file mode 100644
index 00000000000..6e5b8a39b5d
--- /dev/null
+++ b/src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/Queries/IFilterInputObjectGraphType.cs
@@ -0,0 +1,10 @@
+using GraphQL.Types;
+
+namespace OrchardCore.Apis.GraphQL.Queries;
+
+public interface IFilterInputObjectGraphType : IInputObjectGraphType
+{
+ void AddScalarFilterFields(string fieldName, string description);
+
+ void AddScalarFilterFields(Type graphType, string fieldName, string description);
+}
diff --git a/src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/Queries/WhereInputObjectGraphType.cs b/src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/Queries/WhereInputObjectGraphType.cs
index 7d28ba1b445..c084f6af265 100644
--- a/src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/Queries/WhereInputObjectGraphType.cs
+++ b/src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/Queries/WhereInputObjectGraphType.cs
@@ -3,13 +3,6 @@
namespace OrchardCore.Apis.GraphQL.Queries;
-public interface IFilterInputObjectGraphType : IInputObjectGraphType
-{
- void AddScalarFilterFields(string fieldName, string description);
-
- void AddScalarFilterFields(Type graphType, string fieldName, string description);
-}
-
public class WhereInputObjectGraphType : WhereInputObjectGraphType