【发布时间】:2018-06-16 01:24:36
【问题描述】:
我使用graphql-tools 库和makeExecutableSchema 函数通过将架构和解析器传递给它来制作我的架构
这是我的架构:
type Trip {
code: String!
driver: User!
vehicle: Vehicle!
destination: Location!
passengers(page: Int, count: Int): [User!]!
}
type Query {
trip(id: String!): Trip
}
这是我的解析器:
// some imports...
export default {
Query: {
async trip(_, { id }, ctx, info) {
const trip = await Trip.findById(id);
// const page = ???, count = ???
// work on fetch data...
return result;
},
};
我怎样才能得到page 和count 被定义为passengers 的嵌套参数?
【问题讨论】:
-
How to pass root parameters in the resolver function of a nested query? 的可能重复项。查看my answer 了解该问题的详细解决方法。
-
@DanielRearden 使用
graphql-tools时需要访问嵌套参数,我知道它存在于解析器的info参数中,但我不知道如何解析和使用它
标签: node.js graphql apollo-server