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 issue with graphql generation not creating the correct method #1793

Merged
merged 2 commits into from
Feb 3, 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
24 changes: 16 additions & 8 deletions src/Analyzers/GraphqlMutationActionBodyGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ IParameterSymbol parameter
}

var sendRequestExpression = isStream
? streamMediatorRequest(IdentifierName(parameter.Name), cancellationTokenParameter)
: sendMediatorRequest(IdentifierName(parameter.Name), cancellationTokenParameter);
? streamMediatorRequest(IdentifierName(parameter.Name), IdentifierName(mediatorParameter.Name), cancellationTokenParameter)
: sendMediatorRequest(IdentifierName(parameter.Name), IdentifierName(mediatorParameter.Name), cancellationTokenParameter);

if (parameterType.IsRecord)
{
Expand All @@ -137,8 +137,8 @@ IParameterSymbol parameter
InitializerExpression(SyntaxKind.WithInitializerExpression, SeparatedList(expressions))
);
sendRequestExpression = isStream
? streamMediatorRequest(withExpression, cancellationTokenParameter)
: sendMediatorRequest(withExpression, cancellationTokenParameter);
? streamMediatorRequest(withExpression, IdentifierName(mediatorParameter.Name), cancellationTokenParameter)
: sendMediatorRequest(withExpression, IdentifierName(mediatorParameter.Name), cancellationTokenParameter);
}
}
else
Expand Down Expand Up @@ -185,7 +185,11 @@ IParameterSymbol parameter
.WithBody(block.NormalizeWhitespace())
.WithSemicolonToken(Token(SyntaxKind.None));

static ExpressionSyntax sendMediatorRequest(ExpressionSyntax nameSyntax, IParameterSymbol? cancellationTokenParameter)
static ExpressionSyntax sendMediatorRequest(
ExpressionSyntax nameSyntax,
ExpressionSyntax mediatorParameterSyntax,
IParameterSymbol? cancellationTokenParameter
)
{
var arguments = new List<ArgumentSyntax> { Argument(nameSyntax), };
if (cancellationTokenParameter is { })
Expand All @@ -200,7 +204,7 @@ static ExpressionSyntax sendMediatorRequest(ExpressionSyntax nameSyntax, IParame
InvocationExpression(
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName("Mediator"),
mediatorParameterSyntax,
IdentifierName("Send")
)
)
Expand All @@ -222,7 +226,11 @@ static ExpressionSyntax sendMediatorRequest(ExpressionSyntax nameSyntax, IParame
);
}

static ExpressionSyntax streamMediatorRequest(ExpressionSyntax nameSyntax, IParameterSymbol? cancellationTokenParameter)
static ExpressionSyntax streamMediatorRequest(
ExpressionSyntax nameSyntax,
ExpressionSyntax mediatorParameterSyntax,
IParameterSymbol? cancellationTokenParameter
)
{
var arguments = new List<ArgumentSyntax> { Argument(nameSyntax), };
if (cancellationTokenParameter is { })
Expand All @@ -233,7 +241,7 @@ static ExpressionSyntax streamMediatorRequest(ExpressionSyntax nameSyntax, IPara
return InvocationExpression(
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName("Mediator"),
mediatorParameterSyntax,
IdentifierName("CreateStream")
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class RocketMutation
/// <returns></returns>
public partial async Task<LaunchRecordModel> GetRocketLaunchRecord(IMediator mediator, GetRocketLaunchRecord.Request request)
{
var result = await Mediator.Send(request).ConfigureAwait(false);
var result = await mediator.Send(request).ConfigureAwait(false);
return result;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class RocketMutation
/// <returns></returns>
public partial async Task<LaunchRecordModel> GetRocketLaunchRecord(IMediator mediator, GetRocketLaunchRecord.Request request)
{
var result = await Mediator.Send(request).ConfigureAwait(false);
var result = await mediator.Send(request).ConfigureAwait(false);
return result;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class RocketMutation
/// <returns></returns>
public partial async Task<LaunchRecordModel> GetRocketLaunchRecord(IMediator mediator, GetRocketLaunchRecord.Request request)
{
var result = await Mediator.Send(request).ConfigureAwait(false);
var result = await mediator.Send(request).ConfigureAwait(false);
return result;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class RocketMutation
/// <returns></returns>
public partial IAsyncEnumerable<LaunchRecordModel> GetRocketLaunchRecords([HotChocolate.ServiceAttribute] IMediator mediator, GetRocketLaunchRecords.Request request)
{
var result = Mediator.CreateStream(request);
var result = mediator.CreateStream(request);
return result;
}

Expand All @@ -23,7 +23,7 @@ public partial IAsyncEnumerable<LaunchRecordModel> GetRocketLaunchRecords([HotCh
/// <returns></returns>
public partial async Task<LaunchRecordModel> GetRocketLaunchRecord(IMediator mediator, GetRocketLaunchRecord.Request request)
{
var result = await Mediator.Send(request).ConfigureAwait(false);
var result = await mediator.Send(request).ConfigureAwait(false);
return result;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public partial class RocketMutation
{
public partial async Task<RocketModel> GetRocket(IMediator mediator, GetRocket.Request request)
{
var result = await Mediator.Send(request).ConfigureAwait(false);
var result = await mediator.Send(request).ConfigureAwait(false);
return result;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public partial class RocketMutation
{
public partial async Task<RocketModel> Save2Rocket(IMediator mediator, Save2Rocket.Request request, ClaimsPrincipal cp, CancellationToken cancellationToken)
{
var result = await Mediator.Send(request with { ClaimsPrincipal = cp }, cancellationToken).ConfigureAwait(false);
var result = await mediator.Send(request with { ClaimsPrincipal = cp }, cancellationToken).ConfigureAwait(false);
return result;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public partial class RocketMutation
{
public partial async Task<RocketModel> Save2Rocket(IMediator mediator, Save2Rocket.Request request, CancellationToken cancellationToken)
{
var result = await Mediator.Send(request, cancellationToken).ConfigureAwait(false);
var result = await mediator.Send(request, cancellationToken).ConfigureAwait(false);
return result;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public partial class RocketMutation
{
public partial async Task<RocketModel> Save2Rocket(IMediator mediator, ClaimsPrincipal claimsPrincipal, Save2Rocket.Request request)
{
var result = await Mediator.Send(request with { ClaimsPrincipal = claimsPrincipal }).ConfigureAwait(false);
var result = await mediator.Send(request with { ClaimsPrincipal = claimsPrincipal }).ConfigureAwait(false);
return result;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public partial class RocketMutation
{
public partial async Task<RocketModel> Save2Rocket(IMediator mediator, Save2Rocket.Request request, CancellationToken token)
{
var result = await Mediator.Send(request, token).ConfigureAwait(false);
var result = await mediator.Send(request, token).ConfigureAwait(false);
return result;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public partial class RocketMutation
public partial async Task<RocketModel> Save2Rocket(IMediator mediator, Save2Rocket.Request request, ClaimsPrincipal cp)
{
request.ClaimsPrincipal = cp;
var result = await Mediator.Send(request).ConfigureAwait(false);
var result = await mediator.Send(request).ConfigureAwait(false);
return result;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public partial class RocketMutation
{
public partial async Task<RocketModel> Save2Rocket(IMediator mediator, Save2Rocket.Request request)
{
var result = await Mediator.Send(request).ConfigureAwait(false);
var result = await mediator.Send(request).ConfigureAwait(false);
return result;
}
}
Expand Down
Loading