DotNetGraphQLQueryGen
DotNetGraphQLQueryGen copied to clipboard
Query unable generate Input argument with Gql Enum type array.
Input argument with enum array "sex: [Sex!] = null"
input FilterBy {
field: String!
value: String!
sex: [Sex!] = null
}
Test:
public void TestComplexListEnumArg()
{
TestClient client = new TestClient();
QueryRequest query = client.MakeQuery(q => new
{
Producers = q.Producers(new FilterBy { Sex = new List<Sex>() { Sex.Male } }, s => new
{
s.Id,
s.LastName
}),
});
Assert.Equal($@"query BaseGraphQLClient($a0: {{ sex: [""Male""] }}) {{
Producers: producers(filter: $a0) {{
Id: id
LastName: lastName
}}
}
Result:
System.ArgumentException : Can't find GQL type for Dotnet type 'Sex'
I have manually added enum Sex to typeMappings, query not produce correct argument.
public TestClient()
{
typeMappings = new Dictionary<string, string> {
{ "string" , "String" },
{ "String" , "String" },
{ "int" , "Int!" },
{ "Int32" , "Int!" },
{ "double" , "Float!" },
{ "bool" , "Boolean!" },
{ "DateTime" , "Date" },
{ "Sex" , "Sex" },
};
}
Test Result:
Message:
Assert.Equal() Failure
↓ (pos 29)
Expected: ···eGraphQLClient($a0: { sex: ["Male"] }) {\r\nProducers: producer···
Actual: ···eGraphQLClient($a0: [Sex]) {\nProducers: producers(filter: { s···
↑ (pos 29)