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

Mutation inputs are generated as optional despite being non-nullable in schema when using "Request" syntax #94

Open
be1223 opened this issue Feb 14, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@be1223
Copy link

be1223 commented Feb 14, 2024

Describe the bug

When using "Request" syntax, the generated graphql is specifying that the mutation's input is not-nullable when the schema has the input for the same mutation as non-nullable.

This is not the case when using a lambda, in this case the nullability of the input in the generated graphql is correct.

This may also happen with queries, but I've only been using mutations.

How to Reproduce

Define a mutation request with a non-nullable input, it should produce graphql with an optional input.

public sealed record CreateFoo(FooInput Input) : GraphQL<Mutation, int>
{
  public override int Excecute(Mutation query) => query.CreateFoo(Input, static x => x.Id);
}

Expected behavior

Should produce the following correct graphql:

mutation createFoo($input: FooInput!) { id }

Instead produces:

mutation createFoo($input: FooInput) { id }

The same operation using a lambda:

var variables = new { input = new FooInput("Test") }
var id = await client.Mutation(variables, static (v, m) => m.createFoo(v.input, s => s.Id));

This lambda does produce the following:

mutation ($input: FooInput!) { createFoo(input: $input) { id } }

The GraphqQL schema that fails


type Foo {
  id: Int!
}

type FooInput {
  name: String!
}

type Mutation {
  createFoo(
    input: FooInput!
  ): Foo!
}

Screenshots

If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • Nuget package version 6.1.1
  • IDE: Visual Studio
  • OS: Windows 11
  • .Net Version tested on both 6.0.416 and 8.0.100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant