【发布时间】:2019-04-04 20:40:13
【问题描述】:
大家好,我是 Apollo - GraphQL 的新手,我正在使用我的 React Native 应用程序来实现我的服务器。
当我尝试构建密码更改功能时,我收到以下错误this.props.resetPassword is not a function. (In 'this.props.resetPassword(_id, password)', 'this.props.resetPassword' is undefined)
我的代码是这样的
toSend() {
const { _id } = this.props.data.me;
const { password } = this.state;
console.log(_id, password)
this.props
.resetPassword(_id, password)
.then(({ data }) => {
return console.log(data);
})
}
这是我的查询和我的突变
export default graphql(
gql`
query me {
me {
_id
}
}
`,
gql`
mutation resetPassword($_id: String!, $password: String!) {
resetPassword(_id: $_id, password: $password) {
_id
}
}
`,
{
props: ({ mutate }) => ({
resetPassword: (_id, password) => mutate({ variables: { _id, password } }),
}),
},
)(PasswordChange);
【问题讨论】:
标签: reactjs react-native graphql