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 1 commit
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
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<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.Media\OrchardCore.Media.csproj" />
Copy link
Member

@MikeAlhayek MikeAlhayek May 22, 2024

Choose a reason for hiding this comment

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

@tropcicstefan Let's not add this dependency. Two alternative ways to do this

First approach, move the SeoMetaQueryObjectType class into the Media module and register it using the following startup "in the Media startup

[RequireFeatures("OrchardCore.Apis.GraphQL", "OrchardCore.Seo")]
public class Startup : StartupBase
{
    public override void ConfigureServices(IServiceCollection services)
    {
        services.AddObjectGraphType<MetaEntry, MetaEntryQueryObjectType>();
        services.AddObjectGraphType<SeoMetaPart, SeoMetaQueryObjectType>();
    }
}

Second approach, Move both MediaFieldQueryObjectType and MediaAssetObjectType out of OrchardCore.Media and place them into OrchardCore.Media.Core. New the the SEO module can depend on OrchardCore.Media.Core and you are good to go.

However, I am thinking to combine the 2 solutions. The first solution is better but at the same time we should also move MediaFieldQueryObjectType and MediaAssetObjectType out of OrchardCore.Media and place them into OrchardCore.Media.Core.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, but want to know what is the reasoning, why shouldn't it depend on media when it's already dependant with manifest?

Copy link
Member

@MikeAlhayek MikeAlhayek May 22, 2024

Choose a reason for hiding this comment

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

@tropcicstefan In OC, we do not allow a module to reference another module. It's okay for a module to reference on core projects but not a module. It is okay to have dependencies using the Mainifest file, but not project reference.

</ItemGroup>

</Project>