【发布时间】:2020-11-28 13:10:31
【问题描述】:
当我尝试在字段上传递参数参数时,我被卡住了。我收到此错误消息:
"message": "Unknown argument \"limit\" on field \"User.followers\"."
query {
getUser(username: "johnsmith") { # <= this argument is ok
username
followers(limit: 10) { # <= but this one is not
users {
username
}
}
}
}
但我认为我在架构中正确定义了该参数。
type Query {
getUser(username: ID!): User!
followers(limit: Int!): Followers!
}
Query: {
getUser: (_, { username }) => getUser(username),
},
User: {
followers: ({ username }, args) => getAllFollowers(username, args)
}
}
然而,我的 Graphql Playground 自动生成的文档提到了“limit”参数:
followers(
limit: Int!
): Followers!
我错过了什么吗?感谢您的帮助。
【问题讨论】:
标签: graphql apollo-server