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

Incorrect @cost weight for errors field in mutation conventions for custom payloads #7660

Closed
N-Olbert opened this issue Oct 30, 2024 · 0 comments · Fixed by #7691
Closed
Assignees
Milestone

Comments

@N-Olbert
Copy link
Contributor

N-Olbert commented Oct 30, 2024

Product

Hot Chocolate

Version

14.0.0

Link to minimal reproduction

See code sample in issue

Steps to reproduce

When using a custom/user-defined payload type, a @cost weight is emitted. This differs from a non-custom payload type, where no @cost weight is emitted.

Basically, this is a follow-up to #7400

Sample:

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddGraphQLServer().AddQueryType<Query>().AddMutationType<Mutation>().AddMutationConventions();
var app = builder.Build();
app.MapGraphQL();


app.Run();

public record MyThing(string Id);

public class Query
{
    public string Test => "";
}

public class Mutation
{
    [Error<InvalidOperationException>] // Works (no custom payload type)
    public MyThing CreateMyThing() => new("Foo");

    [Error<InvalidOperationException>] // fails (custom payload type)
    public DoSomethingPayload DoSomething() => new DoSomethingPayload(true);
}

public record DoSomethingPayload(bool Foo);

What is expected?

Schema should look like:

type CreateMyThingPayload {
  myThing: MyThing
  errors: [CreateMyThingError!]
}

type DoSomethingPayload {
  foo: Boolean
  errors: [DoSomethingError!]
}

What is actually happening?

Schema looks like:

type CreateMyThingPayload {
  myThing: MyThing
  errors: [CreateMyThingError!]
}

type DoSomethingPayload {
  foo: Boolean
  errors: [DoSomethingError!]  @cost(weight: "10")
}

Relevant log output

No response

Additional context

No response

@N-Olbert N-Olbert changed the title Incorrect @cost weight for errors field in mutation conventions custom payloads Incorrect @cost weight for errors field in mutation conventions for custom payloads Oct 30, 2024
@michaelstaib michaelstaib added this to the HC-14.2.0 milestone Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants