【发布时间】:2019-04-08 22:40:21
【问题描述】:
我想根据job_id: ID! 进行查询,但似乎我做错了什么,我想了解是什么。
所以我在这里接受工作 ID。
render() {
const { job } = this.props.navigation.state.params;
const job_id = job._id;
........
}
所以现在我想在这里使用job_id 进行查询
const GET_APPLICATIONS = gql`
query getJobApplicationsForThisJob($job_id: ID!) {
getJobApplicationsForThisJob(job_id: $job_id) {
_id
}
}
`;
const DELETE_JOB = gql`
mutation deteleJob($_id: ID!) {
deleteJob(_id: $_id) {
message
}
}
`;
const mutationConfig = {
props: ({ mutate, ownProps }) => ({
deleteJob: (_id) => mutate({ variables: { _id } }),
...ownProps,
})
}
export default compose(
withApollo,
graphql(GET_APPLICATIONS, { name: "getApplications" }),
graphql(DELETE_JOB, mutationConfig)
)(JobDetails);
但我最终得到以下错误
Invariant Violation: The operation 'getJobApplicationsForThisJob' wrapping 'JobDetails' is expecting variable 'job_id' but it was not found in the props passed to 'Apollo(JobDetails)'
有什么想法吗?
【问题讨论】:
标签: react-native graphql apollo