GraphQL Mutation用作装饰器

时间:2019-05-19 19:32:15

标签: graphql apollo react-apollo

我有以下graphql突变

const CREATE_USER = gql`
    mutation createUser(
        userInput: {
            email: String!
            password: String!
        }
    ) {
        createUser(
            userInput: {
                email: $email
                password: $password
            }
        ) {
            _id
            email
        }
    }
`;

export default graphql(CREATE_USER, {
    name: 'createUser',
    props: ({createUser}) => ({
        createUser:(email, password) => 
            createUser({
                variables: {
                    email,
                    password
                }
            })
    })
})

导入到另一个文件,例如

import CreateUser from '../graphql/mutations/create-user/create-user';
@CreateUser
class AuthPage extends Component {
   //...
}

(带有装饰器)现在,我有一个在表单提交上运行的函数,我如何告诉apollo从状态中获取一些值并使用它们来运行此突变,然后运行该突变?

0 个答案:

没有答案