Closed Jeroen-Sturm closed 2 years ago
Thanks. Very valid point. I'll hope to fix it during this week.
Hi. I added a new overload new GraphQlQueryParameter<T>("parameterName")
without passing explicit value. The GQL type is by default resolved from the generic parameter but can be overridden using optional parameter. I believe it should solve the problem.
Would be good if you could test it before publishing new nuget package.
Yes @Husqvik Thank you that seems to work nicely, so build it ship it 😄
The only thing now is that :
Variable "someString" of type "String" used in position expecting type "String!".
Im using it like this :
var someStringParameter = new GraphQlQueryParameter<string>("someString");
since this string is not a nullable int I would thing it should be "String!", or how does this works ?
There is yet another constructor that has been already there
new GraphQlQueryParameter<string>("someString", default, isNullable: false)
or in the newly added one you can explicitly specify the GraphQL type
new GraphQlQueryParameter<string>("someString", "String!")
Yes I saw that but I would like another override like so. :
new GraphQlQueryParameter<string>("someString", isNullable: false)
But now I already added explicitly typed types. so it would be a nice to have not a bug ;-)
new GraphQlQueryParameter<string>("someString", isNullable: false)
doesn't make sense as without passing the value the parameter must be nullable
No its not, What if I want to use the variables I spoke about earlier ?
var homeIdParameter = new GraphQlQueryParameter<Guid>("homeId", "UUID!");
var builder =
new TibberQueryBuilder()
.WithViewer(
new ViewerQueryBuilder()
.WithHome(new HomeQueryBuilder().WithAllScalarFields(), homeIdParameter)
)
.WithParameter(homeIdParameter);
var variables = new {
homeId = "SOME GUID",
};
Then it's possible to add "not nullable" parameters without a value. Because they're set in the variables.
Exactly, the value of the parameter is default value. Not actual. For not null parameters (types ending with !
) the value is entirely omitted as it's required to be passed using the variables object.
@Husqvik When will this be published to nuget?
Can you bump https://www.nuget.org/packages/GraphQlClientGenerator as well ?
I knew I forgot something :), sorry. https://www.nuget.org/packages/GraphQlClientGenerator/0.9.13
Used NuGet Packages:
GraphQlClientGenerator version 0.9.12 GraphQl.Client version 5.1.0
Used Language: net6.0
for query-parameters I would like to suggest to implement a possibility to add parameters without values so for example :
So we can use it with
GraphQlHttpClient
which support Variables as seen here. Because in my case I have queries that have nullable parameters but when I fill innull
I get a GraphQL error that says :query looks like :
I would like the builded query to look like(notice there is no parameter value) :