Fix embeded relations error message (#767)

This commit is contained in:
Diogo Biazus
2016-12-10 11:59:17 -08:00
committed by Joe Nelson
parent 15c95399f8
commit 649a841ef4
3 changed files with 16 additions and 11 deletions
+4 -7
View File
@@ -315,10 +315,6 @@ contentRangeH lower upper total =
totalNotZero = fromMaybe True ((/=) 0 <$> total)
fromInRange = lower <= upper
formatRelationError :: Text -> Text
formatRelationError = formatGeneralError
"could not find foreign keys between these entities"
formatParserError :: ParseError -> Text
formatParserError e = formatGeneralError message details
where
@@ -327,14 +323,15 @@ formatParserError e = formatGeneralError message details
$ showErrorMessages "or" "unknown parse error" "expecting" "unexpected" "end of input" (errorMessages e)
formatGeneralError :: Text -> Text -> Text
formatGeneralError message details = toS $ encode $ object [
"message" .= message,
"details" .= details]
formatGeneralError message details = message <> ", " <> details
augumentRequestWithJoin :: Schema -> [Relation] -> ReadRequest -> Either Text ReadRequest
augumentRequestWithJoin schema allRels request =
(first formatRelationError . addRelations schema allRels Nothing) request
>>= addJoinConditions schema
where
formatRelationError = formatGeneralError
"could not find foreign keys between these entities"
addFiltersOrdersRanges :: ApiRequest -> Either ParseError (ReadRequest -> ReadRequest)
addFiltersOrdersRanges apiRequest = foldr1 (liftA2 (.)) [