This module exists for harmonizing queries results with the rest of this package.
Without it, the type of these results would need to be something like Response transportError (Response customError object).
While Response can model any type of errors,
the most common one Paack has encountered is when fetching data from a Graphql query,
and getting back a GraphqlError.
Because of that, GraphqlHttpResponse is provided as a useful alias.
Tranforms Response transportError (Response customError object),
received from a query result, into a Response transportError customError object.
NOTE: Prefer graphqlHttpToMsg and get Response directly in the resulting message.
Prepares a message that will return GraphqlHttpResponse for Graphql usage.
query
|> Graphql.Http.queryRequest "https://..."
|> Graphql.Http.send
(Response.graphqlHttpToMsg Msg.BookingFetched)True when Success _.
NOTE: This function opposes the purpose of this package by eliminating not aimed states. Always evaluate using a switch-case instead.
True when Failure _.
NOTE: This function opposes the purpose of this package by eliminating not aimed states. Always evaluate using a switch-case instead.
True when Failure (Custom _).
NOTE: This function opposes the purpose of this package by eliminating not aimed states. Always evaluate using a switch-case instead.
True when Failure (Transport _).
NOTE: This function opposes the purpose of this package by eliminating not aimed states. Always evaluate using a switch-case instead.
Convert to a simpler Maybe if the actual error message is not needed or
you need to interact with some code that primarily uses maybes.
NOTE: This function opposes the purpose of this package by eliminating not aimed states. Always evaluate using a switch-case instead.
Transforms Failure error into Just error, and Success _ into Nothing.
NOTE: This function opposes the purpose of this package by eliminating not aimed states. Always evaluate using a switch-case instead.
Apply a function to a successful value. If the result is Success, it will be converted.
If the result is a Failure, the same error value will propagate through.
Transform a Failure (Custom a) value. If the result is Failure (Custom a), it will be converted.
If the result is a Success _ or Failure (Transport _), the same value will propagate through.
Transform a Failure (Transport a) value. If the result is Failure (Transport a), it will be converted.
If the result is a Success _ or Failure (Custom _), the same value will propagate through.
Transform a Failure value. If the result is Failure, it will be converted.
If the result is a Success, the same value will propagate through.
If the result is Success return the value,
but if the result is a Failure then return a given default value.
NOTE: This function opposes the purpose of this package by eliminating not aimed states. Always evaluate using a switch-case instead.
A
Remote.Resultis eitherSuccessmeaning the query succeeded, or it is anFailuremeaning that there was some failure.A
Failureis then sub-divided accordingly toRemote.Errors.