将'where'对象传递给动态GraphQL查询
假设我有以下问题:将'where'对象传递给动态GraphQL查询,graphql,Graphql,假设我有以下问题: Foo($account: String!) { foo(where: { account: $account }) { id bar } } 现在一切正常,但我可以替换$account:String参数,如下所示: Foo($where: Object!) { foo(where: $where) { id bar } } ?是,但您需要指定所在位置的确切输入对象类型。该类型取决于您所查询的模式 所以,如果你是,模式就是
Foo($account: String!) {
foo(where: { account: $account }) {
id
bar
}
}
现在一切正常,但我可以替换$account:String代码>参数,如下所示:
Foo($where: Object!) {
foo(where: $where) {
id
bar
}
}
?是,但您需要指定所在位置的确切输入对象类型。该类型取决于您所查询的模式
所以,如果你是,模式就是
type Query {
foo(where: FooWhere!): Foo
}
input FooWhere {
account: String
}
您的查询变为
Foo($where: FooWhere!) {
foo(where: $where) {
id
bar
}
}
如果您要查询某些第三方API,它们应该提供文档或公开GraphiQL或GraphQL接口,您可以在其中查找要使用的适当类型