SAHB.GraphQLClient
SAHB.GraphQLClient copied to clipboard
How do I add arguments to a model nested in the query?
Background
I am trying to generate this query that has arguments passed to a subschema
query($fooId: String! $filter: BarFilter) {
foo(id: $fooId) {
id
... on FooBar {
bars(filter: $filter) {
name
}
}
}
}
Query Classes
public class FooQuery
{
// This works for binding the fooId
[GraphQLArguments("id", "String!", "fooId", isRequired: true, inlineArgument: false)]
[GraphQLUnionOrInterface("FooBar", typeof(FooBar))]
public Foo Foo { get; set; }
}
public class Foo
{
public string Id { get; set; }
}
public class FooBar : Foo
{
// This does not work
[GraphQLArguments("filter", "BarFilter", "filter", isRequired: true, inlineArgument: false)]
public IEnumerable<Bar> Bars { get; set; }
}
public class Bar
{
public string Name { get; set; }
}
Issue
When I supply the filter
it causes GraphQLArgumentVariableNotFoundException
with the message "The arguments with the following variables could not be found: filter".
var args = new GraphQLQueryArgument[]
{
new GraphQLQueryArgument("fooId", string.Empty),
new GraphQLQueryArgument("filter", new { }),
};
What the model generates
The model generates this query with the following arguments
query($fooId:String!) {
foo(id:$fooId) {
id
__typename
... on FooBar {
bars {
name
}
id
}
}
}
var args = new GraphQLQueryArgument[]
{
new GraphQLQueryArgument("fooId", string.Empty),
};
This is clearly an error. I will look on it when I have the time.