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 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using OrchardCore.Apis.GraphQL.Resolvers;
using OrchardCore.ContentManagement.GraphQL.Options;
using OrchardCore.FileStorage;
using OrchardCore.Media.Core.GraphQL;

namespace OrchardCore.Media.GraphQL
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Microsoft.Extensions.Localization;
using OrchardCore.ResourceManagement;

namespace OrchardCore.Seo.GraphQL;
namespace OrchardCore.Media.GraphQL;
MikeAlhayek marked this conversation as resolved.
Show resolved Hide resolved

public class MetaEntryQueryObjectType : ObjectGraphType<MetaEntry>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using GraphQL.Types;
using Microsoft.Extensions.Localization;
using OrchardCore.Media.Fields;
using OrchardCore.Media.Core.GraphQL;
using OrchardCore.Media.GraphQL;
using OrchardCore.Seo.Models;

namespace OrchardCore.Seo.GraphQL;
namespace OrchardCore.Media.GraphQL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not change the namespace here.


public class SeoMetaQueryObjectType : ObjectGraphType<SeoMetaPart>
{
Expand All @@ -28,10 +29,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 +42,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
@@ -1,8 +1,11 @@
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Apis;
using OrchardCore.Apis.GraphQL;
using OrchardCore.Media.Core.GraphQL;
using OrchardCore.Media.Fields;
using OrchardCore.Modules;
using OrchardCore.ResourceManagement;
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.Abstractions\OrchardCore.Seo.Abstractions.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 @@ -29,7 +28,7 @@
<ProjectReference Include="..\..\OrchardCore\OrchardCore.ResourceManagement\OrchardCore.ResourceManagement.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Seo.Abstractions\OrchardCore.Seo.Abstractions.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 @@ -2,7 +2,7 @@
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.FileStorage;

namespace OrchardCore.Media.GraphQL
namespace OrchardCore.Media.Core.GraphQL
{
public class MediaAssetObjectType : ObjectGraphType<IFileStoreEntry>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using OrchardCore.Apis.GraphQL;
using OrchardCore.Media.Fields;

namespace OrchardCore.Media.GraphQL
namespace OrchardCore.Media.Core.GraphQL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not change the namespace to avoid users having to fix their code if they are using this class

{
public class MediaFieldQueryObjectType : ObjectGraphType<MediaField>
{
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Abstraction module should never depend on a core module

</ItemGroup>


Expand Down