I'm trying to build a mutation that accepts a collection. The GraphQL server is written in c# .net core and uses GraphQL.Net.
This is my input type;
public class PupilReportInputType : InputObjectGraphType<PupilReport>
{
public PupilReportInputType()
{
Name = "PupilReportInput";
Field(pr => pr.PupilId);
Field(pr => pr.PupilMetricCollections, type: typeof(ListGraphType<PupilMetricCollectionInputType>));
}
}
Using GraphiQL I tried to post the following mutation;
mutation getPupilReportText($pupilReport: PupilReportInput!) {
getPupilReportText(pupilReport: $pupilReport)
}
with the following variable;
{
"pupilReport": {
"pupilId" : 5,
"pupilMetricCollections": {
"pupilMetricCollection" : {
"pupilId" : 5
}
}
}
}
The response I get is;
{
"errors": [
{
"message": "Variable '$pupilReport.pupilMetricCollections[0]' is invalid. Unable to parse input as a 'PlayerMetricCollectionInput' type. Did you provide a List or Scalar value accidentally?",
"extensions": {
"code": "INVALID_VALUE"
}
}
]
}
If PupilReportInputType
has the PupilMetricCollections
field removed and the mutation variables adjusted similarly then the query behaves as expected (not errors). Similarly if I modify the variable input and PupilReportInputType
so that the field is just PupilMetricCollectionInputType
rather than ListGraphType<PupilMetricCollectionInputType>
then I can get it all working.
How do I pass a collection on PupilMetricCollectionInputType
? Do I need some sort of ListGraphInputType?