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

Fixed Resolver Compiler Issue When Only Having a Node Resolver #7195

Merged
merged 2 commits into from
Jun 26, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void WriteInitializeMethod(ObjectTypeExtensionInfo objectTypeExtension)

using (_writer.IncreaseIndent())
{
if (objectTypeExtension.Resolvers.Length > 0)
if (objectTypeExtension.Resolvers.Length > 0 || objectTypeExtension.NodeResolver is not null)
{
_writer.WriteIndentedLine("const global::{0} bindingFlags =", WellKnownTypes.BindingFlags);
using (_writer.IncreaseIndent())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ namespace HotChocolate.Types;
[ObjectType<Chapter>]
public static partial class ChapterNode
{
public static async Task<Book?> GetBookAsync(
[Parent] Chapter chapter,
BookRepository repository,
CancellationToken cancellationToken)
=> await repository.GetBookAsync(chapter.BookId, cancellationToken);

[NodeResolver]
public static async Task<Chapter?> GetChapterByIdAsync(
ChapterId id,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Threading;
using System.Threading.Tasks;

namespace HotChocolate.Types;

[ObjectType<Chapter>]
public static partial class ChapterNode2
{
public static async Task<Book?> GetBookAsync(
[Parent] Chapter chapter,
BookRepository repository,
CancellationToken cancellationToken)
=> await repository.GetBookAsync(chapter.BookId, cancellationToken);
}
Loading