-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
Description
Background
I'm trying to pass the variables { "foo": {"fooNumber": "0123456789", "systemCode": "BAZ"} }
to this query
query GetFooId(
$foo: FooNumber
) {
foobeta (foo: foo) {
id
}
}
What works
If I use a class that with parameters that are named identically it works.
var = new { number = "0123456789", systemCode = FooSystemType.BAZ };
var arg = new GraphQLQueryArgument("foo", foo));
Issue
However it does not work with a traditionally named class because parameter names are not transformed.
public class FooNumber
{
[GraphQLFieldName("fooNumber")]
public string Number { get; set; }
public FooSystemType SystemCode { get; set; }
}
It generates an SAHB.GraphQLClient.Exceptions.GraphQLHttpExecutorServerErrorStatusCodeException
because of a BadRequest.
Generated Query
Query
query($foo:FooNumber){foobeta(foo:$foo){id}}",
Variables
"foo": {
"Number": "0123456789",
"SystemCode": "BAZ"
}
Response
{
"errors": [
{
"message": "Variable \"$foo\" got invalid value { Number: \"0123456789\", SystemCode: \"BAZ\" }; Field fooNumber of required type String! was not provided."
},
{
"message": "Variable \"$foo\" got invalid value { Number: \"0123456789\", SystemCode: \"BAZ\" }; Field systemCode of required type FooSystemType! was not provided."
},
{
"message": "Variable \"$foo\" got invalid value { Number: \"0123456789\", SystemCode: \"BAZ\" }; Field \"Number\" is not defined by type FooNumber."
},
{
"message": "Variable \"$foo\" got invalid value { Number: \"0123456789\", SystemCode: \"BAZ\" }; Field \"SystemCode\" is not defined by type FooNumber. Did you mean systemCode?"
}
],
}
Query classes
public class FooQuery
{
[GraphQLArguments("foo", "FooNumber", "foo")]
public FooBeta FooBeta { get; set; }
}
[GraphQLFieldName("foobeta")]
public class FooBeta : Foo
{
}
public class Foo
{
public string Id { get; set; }
}
[JsonConverter(typeof(StringEnumConverter))]
public enum FooSystemType
{
[EnumMember(Value = "BAZ")]
BAZ,
}