GraphQl查询中的嵌套字段如何获得自己的参数
我正在研究基于光标的分页,该分页需要嵌套字段才能访问ARGS。到目前为止,我一直无法将Args带到其所需的领域。
type Game {
players(first: Int, after: String, last: Int, before: String): GameToPlayerConnection
}
game(id: GameID!): Game
我只能访问传递给game
的args,而不是传递给players
的args。
game: async (parent: any, args: { id: string; first: number; last: number; after:
string; before: string; }, _ctx: any, info: any) =>
{
const { id, first, last, after, before } = args;
console.log("args", args);
}
game(id: 'fortnite', first: 3){
players(first: 2){
....
}
}
我正在尝试访问传递给players
的args
I'm working on a cursor based pagination that requires the a nested field to access the args. So far, i've been unable to get the args to its desired field.
type Game {
players(first: Int, after: String, last: Int, before: String): GameToPlayerConnection
}
game(id: GameID!): Game
I am able to only access the args passed to the game
and not the args passed to the players
.
game: async (parent: any, args: { id: string; first: number; last: number; after:
string; before: string; }, _ctx: any, info: any) =>
{
const { id, first, last, after, before } = args;
console.log("args", args);
}
game(id: 'fortnite', first: 3){
players(first: 2){
....
}
}
I am trying to access the args passed to the players
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没错。每个解析器只能访问其自身属性的参数。每个对象也都有其自己的一组解析器,因此您需要一个对象进行查询,另一个对象进行游戏:
That's correct. Every resolver can only access the arguments for its own property. Each object also has its own set of resolvers, so you need one object for Query, and another for Game: