-
Notifications
You must be signed in to change notification settings - Fork 52
Description
Hi. I have a few questions regarding GraphQlQueryParameter<T>
and QueryBuilderParameter<T>
design.
The first one is used to create the parametrized query (WithParameter
method). The second is to provide an inline arguments value or parameter name (With{FIELD}
methods).
GraphQlQueryParameter<T>
has a few constructors. When using
public GraphQlQueryParameter(string name, string graphQlTypeName = null)
I expect the nullability to be inferred from the T
nullability, including respecting the NRT if enabled. But instead, it always creates nullable arguments. For example, Int
instead of Int!
. It also seems to have a bug in the following line because ?
shouldn't be appended to the graphql type name:
var nullableSuffix = nullableUnderlyingType == null ? null : "?";
So, my question is if there is any reason why this constructor won't be able to infer the nullability from the T
?
- There is an additional constructor.
public GraphQlQueryParameter(string name, T defaultValue, bool isNullable = true)
That allows to define the nullability manually, but T defaultValue
is required in this constructor. Any reason why I can't override the nullability without specifying the default value?
- The
QueryBuilderParameter<T>
doesn't have public constructors. This forces me to useGraphQlQueryParameter<T>
and provide redundant parameters like graphql type name orisNullable
and enforces validations that are not relevant here. I understand that I can reuse an instance that was passed intoWithParameter
but it makes the API "less fluent". I also understand that adding a public constructor with a single argument for a parameter name will create ambiguity with a private constructor whenT
isstring
, but maybe design can be changed slightly to allow simple creation of theQueryBuilderParameter<T>
instance.