viewModelScope.launch {
val req = RequestCodeMutation(phoneNumber)
val response = try {
ApolloClientManager
.apolloClient
.suspendMutate(req)
}
catch (e: ApolloException) {
println(e.message)
isError.value = true
null
}
finally {
loading.value = false
}
val requestCode = response?.data?.requestCode
println(response?.errors)
}
suspend fun <D : Operation.Data, T, V : Operation.Variables> ApolloClient.suspendMutate(mutation: Mutation<D, T, V>): Response<T> =
mutate(mutation).toDeferred().await()
This is my validator on server side. It is shown correctly on Graphiql, however, I am unable to receive this message on client side.
requestCode = async (resolve, source, args, context, info) => {
let { phoneNumber } = args;
phoneNumber = validator.trim(phoneNumber);
Object.assign(args, { phoneNumber });
if (!validator.isMobilePhone(phoneNumber)) {
throw new UserInputError('Invalid phone number provided!');
}
return resolve(source, args, context, info);
}
ApolloException.message
is showing Internal Server Error and response?.errors
is null
.
response?.errors
is not supposed to be null
and show the proper error message that is being shown on GraphiQL.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…