question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nullable input type

See original GitHub issue

First of all great work with this! Really like the developer experience using this generator. However, I encountered an issue (it might be me missing something rather than an issue 😄)

Have the following input type defined:

public record ModifyUnitAdministatorInput(
        int Id,
        Optional<string?> Cvr,
        Optional<string?> CompanyName,
        );

and mutation signature:

public async Task<ModifyUnitAdministratorPayload> ModifyUnitAdministator(
            ModifyUnitAdministatorInput input, [Service] ApplicationDbContext dbContext) {...}

Generating the client:

var schema = await GraphQlGenerator.RetrieveSchema(url);
var csharpCode = new GraphQlGenerator().GenerateFullClientCSharpFile(schema, clientName);

Then I get some strange queries when building with nullable values:

string? value = null;
var unitAdminInput = new ModifyUnitAdministatorInput{ Cvr = value };
var mutationBuilder = new MutationQueryBuilder()
                .WithModifyUnitAdministator(
                    new ModifyUnitAdministratorPayloadQueryBuilder()
                        .WithUnitAdministrator(
                            new UnitAdministratorQueryBuilder()
                                .WithCvr()
                            )
                        , unitAdminInput);

"mutation{
    modifyUnitAdministator(input:{
        cvr:\"GraphQLApiClient.QueryBuilderParameter`1[System.String]\"
   })
   {
     unitAdministrator { cvr }
   }
}"

Am I doing something wrong?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Husqvikcommented, Feb 14, 2021

Fixed, do you need a new nuget?

Read more comments on GitHub >

github_iconTop Results From Across the Web

input type="number" contains null rather than character
1 Answer 1 ... If you type something into a "number" input that's not a number, the value will be null . That's...
Read more >
nullable inputs/args are not covered in the docs very well
for InputType and Args it is important to distinguish that null is a totally valid input when fields/args are marked nullable: true -...
Read more >
Number Input, Allow null value, how do I set it to null?
I'm reading in some data into a Number Input. I have checked the "Allow null value" setting. I don't want it to default...
Read more >
Using nullability in GraphQL
By default, every field in GraphQL is nullable, and you can opt in to mark it non-null. In this article, we'll go over...
Read more >
No input field null validation on non nullable fields
2.9. 5 deals exclusively with inputs. Null values can either be specifically provided as null or understood as null if not given. GraphQL...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found