GraphQL Apollo 接收未定义的数据对象

GraphQL Apollo recieving data object undefined

我正在做一个突变,它需要一个用户名和密码,并且从服务器得到一个登录响应作为响应。

<Mutation mutation={SIGN_UP}>
        {(signUp, data) => (
         <form onSubmit={e => {
            e.preventDefault();
            signUp({
                 variables: { 
                    user: {
                    "email": input_email.value as String, 
                    "password": input_password.value as String
                    }
                }
            });
            console.log("Signup", signUp)
            console.log("Data", data.data);

            input_email.value = "";
            input_password.value = "";
         }}>
            <div className="col-sm">
                <div className="signin__header">Signup IMPACT R&D</div>
            </div>
            <div className="col-sm signin__input" >
                <div className="signin__input__header" >Email</div>
                <input className="signin__input__email" type="text" placeholder="Enter email" required ref={node=> {input_email = node}}></input>
                <div className="signin__divide-line"></div>
            </div>
            <div className="col-sm signin__input">
                <div className="signin__input__header" >Password</div>
                <input className="signin__input__password" type="password" placeholder="Enter password" ref={node=> {input_password = node}}></input>
                <div className="signin__divide-line"></div>
            </div>
            <div className="col-sm-3">
                <button className="signin__input__button" type="submit">Sign Up</button>
            </div>
         </form>
    )}
</Mutation>

这是我的 GraphQLtag。

 export const SIGN_UP : any = gql`
 mutation Register($user: UserInput!) {
    register(user: $user) {
        status,
        refreshToken,
        token,
        error
    }
 } 
`;

在浏览器网络中我可以看到我收到了数据。但是当我尝试将其打印出来时,我的数据对象仍然为空...帮助!

发现我需要在注册后等待带有 then promise 的响应

}).then ((res: any) => {
errorMessage = res.data.register.token;
});