例如,我有一个连接类型:
let usersType = new GraphQLObjectType({
name: 'Users',
description: 'users array',
fields: () => ({
array: {
type: userConnection,
description: 'all users',
args: connectionArgs,
searchFor: {
type: GraphQLString
},
resolve: (root, args) => {
return connectionFromArray(get(), args);
}
}
})
});在这种情况下,在查询中,我只能指定(first,last,after,before)参数,但是如果我需要传递一些额外的参数,比如userName等,这是可能的吗?
基本上,我需要这样的东西:
query {
array (first: 1, userName: "name")
}在用户类型中,我可以像这样处理请求:
resolve: (root, args) => connectionFromArray(get(args.userName), args.args)https://stackoverflow.com/questions/38297058
复制相似问题