GraphQL.net Variables 为 InputObjectGraphType 类型时报错一例

报错信息为:variable support issue in mutations: "Variable '$input' is invalid. Unable to parse input as a 'heroInput' type. Did you provide a List or Scalar value accidentally?"

原因为 Controller Post 参数解析 GraphQLRequest 不是使用 GraphQLSerializer 解析,InputObjectGraphType 类型参数没有解析为 IDictionary<string, object> (GraphQL.net 官方 Examples 太久没更新)

1 public async Task<HttpResponseMessage> PostAsync(HttpRequestMessage request, GraphQLRequest query)

使用 GraphQLSerializer 解析后正常

var query = new GraphQLSerializer().Deserialize<GraphQLRequest>(requestJson);

 

posted @ 2023-03-22 20:00  [木鸟]  阅读(48)  评论(0编辑  收藏  举报