Marco Pierucci
07/18/2022, 2:11 PMcustomAttributes
Now Im trying to update to apollo 3.4 and switched to nonStandardFields
as suggested.
But now when getting refresh token errors, nonStandardFields
come as null and the actual erros come as:
extensions = {errorClass=VALIDATION, validationErrors=[{message=Please make sure the refresh token is correct., inputPath=[input, input]}]}
extension being : Map<String, Any?>?
🤔mbonnin
07/18/2022, 2:12 PMMarco Pierucci
07/18/2022, 2:13 PMNetworkException(errors=[Error(message = Invalid data, locations = [Location(line = 1, column = 65)], path=[obtainCoconutToken], extensions = {errorClass=VALIDATION, validationErrors=[{message=Please make sure the refresh token is correct., inputPath=[input, input]}]}, nonStandardFields = null)])
mbonnin
07/18/2022, 2:13 PMresponse.errors[0].extensions["errorClass"] as? String
Marco Pierucci
07/18/2022, 2:26 PMerrorClass
or validationsError
that could easily change on an update an break my app?mbonnin
07/18/2022, 2:27 PMresponse.errors[0].extensions["validationErrors"] as? List<Map<String, Any?>>
(response.errors[0].extensions["validationErrors"] as? List<Map<String, Any?>>).get(0).get("message")
Marco Pierucci
07/18/2022, 2:28 PMmbonnin
07/18/2022, 2:28 PMMarco Pierucci
07/18/2022, 2:29 PMMartin Bonnin [4:28 PM]
Yep.Ah ok
mbonnin
07/18/2022, 2:29 PMinline fun <reified T> Any?.cast() = this as T
val Any?.asMap: Map<String, Any?>
get() = this.cast()
val Any?.asList: List<Any?>
get() = this.cast()
val Any?.asString: String
get() = this.cast()
val Any?.asBoolean: String
get() = this.cast()
val Any?.asNumber: Number
get() = this.cast()
response.errors[0].extensions["validationErrors"].asList[0].asMap["message"]
I know its not the same but on apollo 2 and before seems like we could look for it in customAttributes so maybe it should be showing in non standardFields on 3.x and above?The ways your server answers is actually standard 🙂 . It's all in "extensions" so it's all good
Marco Pierucci
07/18/2022, 2:31 PMmbonnin
07/18/2022, 2:31 PM