You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Version 11 made Graphqelm.Http.Error to be different types. So something like this is not possible anymore:
typeMsg=MonkeyFetched (ResultGrapheqlm.Http.ErrorMonkey)
|MonkeyCreated (ResultGrapheqlm.Http.ErrorCreateMonkeyMutationResponse)
case msg ofMonkeyFetched result ->case result ofErr err ->
({model | monkey =Failure err})
....MonkeyCreated result ->case result ofErr err ->
({model | monkey =Failure err})
In the above case it make sense to treat the fetch and creation in a similar way. Having the error being different types prevents this from compiling.
The error type needs to be homogenised first e.g.
mapGraphelmError : (a -> b) ->Graphqelm.Http.Error a ->Graphqelm.Http.Error b
mapGraphelmError fn error=caseerrorofGraphqelm.Http.HttpError e ->Graphqelm.Http.HttpError e
Graphqelm.Http.GraphqlError parsedData errors ->case parsedData ofGraphqelm.Http.GraphqlError.ParsedData parsed ->Graphqelm.Http.GraphqlError (Graphqelm.Http.GraphqlError.ParsedData (fn parsed)) errors
Graphqelm.Http.GraphqlError.UnparsedData v ->Graphqelm.Http.GraphqlError (Graphqelm.Http.GraphqlError.UnparsedData v) errors
And then
typeMsg=MonkeyFetched (Result (Grapheqlm.Http.Error (MaybeMonkey)) (MaybeMonkey))
|MonkeyCreated (Result (Grapheqlm.Http.ErrorCreateMonkeyMutationResponse) CreateMonkeyMutationResponse)
MonkeyCreated result ->case result ofErr mutationErr ->let
err =
mapGraphelmError
(always Nothing)
mutationErr
in
( { model |data=RemoteData.Failure err }
, ...
)
So, consider adding a mapError function unless there is better solution.
The text was updated successfully, but these errors were encountered:
Version 11 made
Graphqelm.Http.Error
to be different types. So something like this is not possible anymore:In the above case it make sense to treat the fetch and creation in a similar way. Having the error being different types prevents this from compiling.
The error type needs to be homogenised first e.g.
And then
So, consider adding a
mapError
function unless there is better solution.The text was updated successfully, but these errors were encountered: