我在graphql中有点新鲜,而且我不知道在客户端调用变异时我是否会出现语法错误,但是当我在图形上进行变异时它会正常运行所以我猜这是客户的问题 graphiql:
mutation createUser {
createUser (user:
{
name: "Apollo"
email: "mail@mail.com"
phoneNumber: "55219938385893"
birthday: 1993
}
){
id
}
}
createUser.ts
import gql from 'graphql-tag'
export const createUser = gql`
mutation createUser(
$email: String
$name: string
$birthday: String
$phoneNumber: String
) {
createUser(
name: $name
email: $email
birthday: $birthday
phoneNumber: $phoneNumber
) {
id
}
}
`
signUpFormContainer.tsx
<Mutation mutation={createUser}>
{(createUser, { data, error, loading }) => (
<View style={styles.container}>
<SignUpForm
loading={loading}
onSubmit={(name, birthday, email, phoneNumber) => {
console.log(name, birthday, email, phoneNumber)
createUser({
variables: {
phoneNumber,
email,
birthday,
name
}
})
console.log(data, error)
}}
/>
{/* {!loading && !error && console.log(data)} */}
</View>
)}
</Mutation>
任何人都有提示可能出现错误的提示?感谢