【发布时间】:2019-04-11 04:36:59
【问题描述】:
所以我必须做两个查询。 First 将返回一个包含多个对象的数组,我想获取第一个对象的 ID 以在我的第二个查询中使用它。
问题是我不能使用b_id: props.getBusiness.business[0]._id
知道如何使用它吗?
const GET_USER_BUSINESS = gql`
query getUserBusiness {
getUserBusiness {
_id
}
}
`;
const GET_BUSINESS_JOBS = gql`
query getBusinessJobs($b_id: ID!) {
getBusinessJobs(b_id: $b_id ) {
_id
name
}
}
`;
export default compose(
withApollo,
graphql(GET_USER_BUSINESS,
{
name: "business"
}),
graphql(GET_BUSINESS_JOBS,
{
name: "jobs",
options: (props) => (
{
variables:
{
b_id: props.getUserBusiness.business[0].b_id
}
}
)
})
)(ProposalContainer);
【问题讨论】:
-
这个服务器端你也管吗?
-
@DavidMaze 不,这只是一个查询
-
getUserBusiness听起来它会返回单个对象而不是数组......是吗?
标签: reactjs react-native graphql