Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent crashing crashing the GraphQL schema when SEO feature is also enabled #16141

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions OrchardCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Email.Smtp", "s
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Rules.Core", "src\OrchardCore\OrchardCore.Rules.Core\OrchardCore.Rules.Core.csproj", "{4BAA08A2-878C-4B96-86BF-5B3DB2B6C2C7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrchardCore.Seo.Core", "src\OrchardCore\OrchardCore.Seo.Core\OrchardCore.Seo.Core.csproj", "{30FA935D-84C0-4EF8-869C-E4C97F541D28}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1384,6 +1386,10 @@ Global
{4BAA08A2-878C-4B96-86BF-5B3DB2B6C2C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4BAA08A2-878C-4B96-86BF-5B3DB2B6C2C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4BAA08A2-878C-4B96-86BF-5B3DB2B6C2C7}.Release|Any CPU.Build.0 = Release|Any CPU
{30FA935D-84C0-4EF8-869C-E4C97F541D28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30FA935D-84C0-4EF8-869C-E4C97F541D28}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30FA935D-84C0-4EF8-869C-E4C97F541D28}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30FA935D-84C0-4EF8-869C-E4C97F541D28}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1623,6 +1629,7 @@ Global
{C35AB37B-5A09-4896-BEEE-B126B7E7018A} = {A066395F-6F73-45DC-B5A6-B4E306110DCE}
{E8A1097D-A65A-4B17-A3A2-F50D79552732} = {A066395F-6F73-45DC-B5A6-B4E306110DCE}
{4BAA08A2-878C-4B96-86BF-5B3DB2B6C2C7} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{30FA935D-84C0-4EF8-869C-E4C97F541D28} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {46A1D25A-78D1-4476-9CBF-25B75E296341}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using GraphQL.Types;
using Microsoft.Extensions.Localization;
using OrchardCore.Media.Fields;
using OrchardCore.Media.GraphQL;
using OrchardCore.Seo.Models;

namespace OrchardCore.Seo.GraphQL;
Expand Down Expand Up @@ -28,10 +28,10 @@ public SeoMetaQueryObjectType(IStringLocalizer<SeoMetaQueryObjectType> S)
Field<ListGraphType<MetaEntryQueryObjectType>>("customMetaTags")
.Resolve(ctx => ctx.Source.CustomMetaTags);

Field<ObjectGraphType<MediaField>>("defaultSocialImage")
Field<MediaFieldQueryObjectType>("defaultSocialImage")
.Resolve(ctx => ctx.Source.DefaultSocialImage);

Field<ObjectGraphType<MediaField>>("openGraphImage")
Field<MediaFieldQueryObjectType>("openGraphImage")
.Resolve(ctx => ctx.Source.OpenGraphImage);

Field(x => x.OpenGraphType, true)
Expand All @@ -41,7 +41,7 @@ public SeoMetaQueryObjectType(IStringLocalizer<SeoMetaQueryObjectType> S)
Field(x => x.OpenGraphDescription, true)
.Description("The seo meta opengraph description");

Field<ObjectGraphType<MediaField>>("twitterImage")
Field<MediaFieldQueryObjectType>("twitterImage")
.Resolve(ctx => ctx.Source.TwitterImage);

Field(x => x.TwitterTitle, true)
Expand Down
13 changes: 13 additions & 0 deletions src/OrchardCore.Modules/OrchardCore.Media/GraphQL/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
using OrchardCore.Apis.GraphQL;
using OrchardCore.Media.Fields;
using OrchardCore.Modules;
using OrchardCore.ResourceManagement;
using OrchardCore.Seo.GraphQL;
using OrchardCore.Seo.Models;

namespace OrchardCore.Media.GraphQL
{
Expand All @@ -16,4 +19,14 @@ public override void ConfigureServices(IServiceCollection services)
services.AddTransient<MediaAssetObjectType>();
}
}

[RequireFeatures("OrchardCore.Apis.GraphQL", "OrchardCore.Seo")]
public class SeoStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddObjectGraphType<MetaEntry, MetaEntryQueryObjectType>();
services.AddObjectGraphType<SeoMetaPart, SeoMetaQueryObjectType>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Navigation.Core\OrchardCore.Navigation.Core.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Recipes.Abstractions\OrchardCore.Recipes.Abstractions.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.ResourceManagement\OrchardCore.ResourceManagement.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Seo.Core\OrchardCore.Seo.Core.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Shortcodes.Abstractions\OrchardCore.Shortcodes.Abstractions.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.XmlRpc.Abstractions\OrchardCore.XmlRpc.Abstractions.csproj" />
</ItemGroup>
Expand Down
17 changes: 0 additions & 17 deletions src/OrchardCore.Modules/OrchardCore.Seo/GraphQL/Startup.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

<ItemGroup>
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Admin.Abstractions\OrchardCore.Admin.Abstractions.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Apis.GraphQL.Abstractions\OrchardCore.Apis.GraphQL.Abstractions.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.ContentManagement\OrchardCore.ContentManagement.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.ContentManagement.Display\OrchardCore.ContentManagement.Display.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.ContentManagement.Abstractions\OrchardCore.ContentManagement.Abstractions.csproj" />
Expand All @@ -28,8 +27,9 @@
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Recipes.Abstractions\OrchardCore.Recipes.Abstractions.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.ResourceManagement\OrchardCore.ResourceManagement.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Seo.Abstractions\OrchardCore.Seo.Abstractions.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Seo.Core\OrchardCore.Seo.Core.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Shortcodes.Abstractions\OrchardCore.Shortcodes.Abstractions.csproj" />
<ProjectReference Include="..\OrchardCore.Indexing\OrchardCore.Indexing.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Indexing.Abstractions\OrchardCore.Indexing.Abstractions.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\OrchardCore.ContentManagement.GraphQL\OrchardCore.ContentManagement.GraphQL.csproj" />
<ProjectReference Include="..\OrchardCore.FileStorage.Abstractions\OrchardCore.FileStorage.Abstractions.csproj" />
<ProjectReference Include="..\OrchardCore.Media.Abstractions\OrchardCore.Media.Abstractions.csproj" />
</ItemGroup>
Expand Down
24 changes: 24 additions & 0 deletions src/OrchardCore/OrchardCore.Seo.Core/OrchardCore.Seo.Core.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<RootNamespace>OrchardCore.Seo.Core</RootNamespace>
<!-- NuGet properties-->
<Title>OrchardCore Seo Core</Title>
<Description>
$(OCCMSDescription)

Core Implementation for Seo module.
</Description>
<PackageTags>$(PackageTags) OrchardCoreCMS</PackageTags>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\OrchardCore.ContentManagement.Abstractions\OrchardCore.ContentManagement.Abstractions.csproj" />
<ProjectReference Include="..\OrchardCore.Media.Core\OrchardCore.Media.Core.csproj" />
</ItemGroup>

</Project>