【发布时间】:2020-12-08 00:24:46
【问题描述】:
当我在 React 中使用 Apollo Client 调用 .NET GraphQL 后端时,我遇到了一个奇怪的问题。
由于某些未知原因,我的字符串类型出现以下错误:
Cannot convert value to AST
如果我使用 fetch 或 axios 发布查询和突变,我的后端工作正常,但这个错误只发生在 Apollo。
由于 Apollo,我不得不将我的 Variables 类型更改为 Inputs 而不是 JObject,并且错误开始发生。
这是我的新 GraphQL 请求类:
using GraphQL;
namespace xyz.com
{
public class GraphQLQuery
{
public string OperationName { get; set; }
public string NamedQuery { get; set; }
public string Query { get; set; }
public Inputs Variables { get; set; }
}
}
以前是这样的:
public class GraphQLQuery
{
public string OperationName { get; set; }
public string NamedQuery { get; set; }
public string Query { get; set; }
public JObject Variables { get; set; }
}
如果我使用 JObject,我会在我的 post 方法中通过 Apollo 调用得到一个空对象。
【问题讨论】:
标签: .net graphql apollo-client