@@ -172,17 +172,17 @@ wrappedReadPlan :: QualifiedIdentifier -> AppConfig -> SchemaCache -> ApiRequest
172172wrappedReadPlan identifier conf sCache apiRequest@ ApiRequest {iPreferences= Preferences {.. },.. } headersOnly = do
173173 qi <- findTable identifier sCache
174174 rPlan <- readPlan qi conf sCache apiRequest
175- (handler, mediaType) <- mapLeft ApiRequestError $ negotiateContent conf apiRequest qi iAcceptMediaType (dbMediaHandlers sCache) (hasDefaultSelect rPlan)
176- if not (null invalidPrefs) && preferHandling == Just Strict then Left $ ApiRequestError $ InvalidPreferences invalidPrefs else Right ()
175+ (handler, mediaType) <- mapLeft ApiRequestErr $ negotiateContent conf apiRequest qi iAcceptMediaType (dbMediaHandlers sCache) (hasDefaultSelect rPlan)
176+ if not (null invalidPrefs) && preferHandling == Just Strict then Left $ ApiRequestErr $ InvalidPreferences invalidPrefs else Right ()
177177 return $ WrappedReadPlan rPlan SQL. Read handler mediaType headersOnly qi
178178
179179mutateReadPlan :: Mutation -> ApiRequest -> QualifiedIdentifier -> AppConfig -> SchemaCache -> Either Error CrudPlan
180180mutateReadPlan mutation apiRequest@ ApiRequest {iPreferences= Preferences {.. },.. } identifier conf sCache = do
181181 qi <- findTable identifier sCache
182182 rPlan <- readPlan qi conf sCache apiRequest
183183 mPlan <- mutatePlan mutation qi apiRequest sCache rPlan
184- if not (null invalidPrefs) && preferHandling == Just Strict then Left $ ApiRequestError $ InvalidPreferences invalidPrefs else Right ()
185- (handler, mediaType) <- mapLeft ApiRequestError $ negotiateContent conf apiRequest qi iAcceptMediaType (dbMediaHandlers sCache) (hasDefaultSelect rPlan)
184+ if not (null invalidPrefs) && preferHandling == Just Strict then Left $ ApiRequestErr $ InvalidPreferences invalidPrefs else Right ()
185+ (handler, mediaType) <- mapLeft ApiRequestErr $ negotiateContent conf apiRequest qi iAcceptMediaType (dbMediaHandlers sCache) (hasDefaultSelect rPlan)
186186 return $ MutateReadPlan rPlan mPlan SQL. Write handler mediaType mutation qi
187187
188188callReadPlan :: QualifiedIdentifier -> AppConfig -> SchemaCache -> ApiRequest -> InvokeMethod -> Either Error CrudPlan
@@ -204,15 +204,15 @@ callReadPlan identifier conf sCache apiRequest@ApiRequest{iPreferences=Preferenc
204204 (Inv , Routine. Immutable ) -> SQL. Read
205205 (Inv , Routine. Volatile ) -> SQL. Write
206206 cPlan = callPlan proc apiRequest paramKeys args rPlan
207- (handler, mediaType) <- mapLeft ApiRequestError $ negotiateContent conf apiRequest relIdentifier iAcceptMediaType (dbMediaHandlers sCache) (hasDefaultSelect rPlan)
208- if not (null invalidPrefs) && preferHandling == Just Strict then Left $ ApiRequestError $ InvalidPreferences invalidPrefs else Right ()
207+ (handler, mediaType) <- mapLeft ApiRequestErr $ negotiateContent conf apiRequest relIdentifier iAcceptMediaType (dbMediaHandlers sCache) (hasDefaultSelect rPlan)
208+ if not (null invalidPrefs) && preferHandling == Just Strict then Left $ ApiRequestErr $ InvalidPreferences invalidPrefs else Right ()
209209 failMaxAffectedRpcReturnsSingle (preferMaxAffected, preferHandling) proc
210210 return $ CallReadPlan rPlan cPlan txMode proc handler mediaType invMethod identifier
211211 where
212212 qsParams' = QueryParams. qsParams iQueryParams
213213
214214 failMaxAffectedRpcReturnsSingle :: (Maybe PreferMaxAffected , Maybe PreferHandling ) -> Routine -> Either Error ()
215- failMaxAffectedRpcReturnsSingle (Just (PreferMaxAffected _), Just Strict ) rout = if funcReturnsSingle rout then Left $ ApiRequestError MaxAffectedRpcViolation else Right ()
215+ failMaxAffectedRpcReturnsSingle (Just (PreferMaxAffected _), Just Strict ) rout = if funcReturnsSingle rout then Left $ ApiRequestErr MaxAffectedRpcViolation else Right ()
216216 failMaxAffectedRpcReturnsSingle _ _ = Right ()
217217
218218hasDefaultSelect :: ReadPlanTree -> Bool
@@ -225,7 +225,7 @@ inspectPlan apiRequest headersOnly schema = do
225225 accepts = iAcceptMediaType apiRequest
226226 mediaType <- if not . null $ L. intersect accepts producedMTs
227227 then Right MTOpenAPI
228- else Left . ApiRequestError . MediaTypeError $ MediaType. toMime <$> accepts
228+ else Left . ApiRequestErr . MediaTypeError $ MediaType. toMime <$> accepts
229229 return $ InspectPlan mediaType SQL. Read headersOnly schema
230230
231231{-|
@@ -784,7 +784,7 @@ hoistIntoRelSelectFields _ r = r
784784-- to order once it's aggregated if it's not selected in the inner query beforehand.
785785addToManyOrderSelects :: ReadPlanTree -> Either Error ReadPlanTree
786786addToManyOrderSelects (Node rp@ ReadPlan {order, select, relAggAlias, relSelect, relSpread = Just ToManySpread {}} forest)
787- | anyAggSel || anyAggRelSel = Left $ ApiRequestError $ NotImplemented " Aggregates are not implemented for one-to-many or many-to-many spreads."
787+ | anyAggSel || anyAggRelSel = Left $ ApiRequestErr $ NotImplemented " Aggregates are not implemented for one-to-many or many-to-many spreads."
788788 | otherwise = Node rp { order = [] , relSpread = newRelSpread } <$> addToManyOrderSelects `traverse` forest
789789 where
790790 newRelSpread = Just ToManySpread { stExtraSelect = addSprExtraSelects, stOrder = addSprOrder}
@@ -806,7 +806,7 @@ addToManyOrderSelects (Node rp forest) = Node rp <$> addToManyOrderSelects `trav
806806
807807validateAggFunctions :: Bool -> ReadPlanTree -> Either Error ReadPlanTree
808808validateAggFunctions aggFunctionsAllowed (Node rp@ ReadPlan {select} forest)
809- | not aggFunctionsAllowed && any (isJust . csAggFunction) select = Left $ ApiRequestError AggregatesNotAllowed
809+ | not aggFunctionsAllowed && any (isJust . csAggFunction) select = Left $ ApiRequestErr AggregatesNotAllowed
810810 | otherwise = Node rp <$> traverse (validateAggFunctions aggFunctionsAllowed) forest
811811
812812-- | Lookup table in the schema cache before creating read plan
@@ -860,9 +860,9 @@ addRelatedOrders (Node rp@ReadPlan{order,from} forest) = do
860860 name = fromMaybe relName relAlias in
861861 if isToOne == Just True
862862 then Right $ cot{coRelation= relAggAlias}
863- else Left $ ApiRequestError $ RelatedOrderNotToOne (qiName from) name
863+ else Left $ ApiRequestErr $ RelatedOrderNotToOne (qiName from) name
864864 Nothing ->
865- Left $ ApiRequestError $ NotEmbedded coRelation
865+ Left $ ApiRequestErr $ NotEmbedded coRelation
866866
867867-- | Searches for null filters on embeds, e.g. `projects=not.is.null` on `GET /clients?select=*,projects(*)&projects=not.is.null`
868868--
@@ -956,7 +956,7 @@ addRanges ApiRequest{..} rReq =
956956 _ -> foldr addRangeToNode (Right rReq) =<< ranges
957957 where
958958 ranges :: Either Error [(EmbedPath , NonnegRange )]
959- ranges = first (ApiRequestError . QueryParamError ) $ QueryParams. pRequestRange `traverse` HM. toList iRange
959+ ranges = first (ApiRequestErr . QueryParamError ) $ QueryParams. pRequestRange `traverse` HM. toList iRange
960960
961961 addRangeToNode :: (EmbedPath , NonnegRange ) -> Either Error ReadPlanTree -> Either Error ReadPlanTree
962962 addRangeToNode = updateNode (\ r (Node q f) -> Node q{range_= r} f)
@@ -990,7 +990,7 @@ updateNode f ([], a) rr = f a <$> rr
990990updateNode _ _ (Left e) = Left e
991991updateNode f (targetNodeName: remainingPath, a) (Right (Node rootNode forest)) =
992992 case findNode of
993- Nothing -> Left $ ApiRequestError $ NotEmbedded targetNodeName
993+ Nothing -> Left $ ApiRequestErr $ NotEmbedded targetNodeName
994994 Just target ->
995995 (\ node -> Node rootNode $ node : delete target forest) <$>
996996 updateNode f (remainingPath, a) (Right target)
@@ -1014,7 +1014,7 @@ mutatePlan mutation qi ApiRequest{iPreferences=Preferences{..}, ..} SchemaCache{
10141014 _ -> False ) qsFiltersRoot
10151015 then mapRight (\ typedColumns -> Insert qi typedColumns body (Just (MergeDuplicates , pkCols)) combinedLogic returnings mempty False ) typedColumnsOrError
10161016 else
1017- Left $ ApiRequestError InvalidFilters
1017+ Left $ ApiRequestErr InvalidFilters
10181018 MutationDelete -> Right $ Delete qi combinedLogic returnings
10191019 where
10201020 ctx = ResolverContext dbTables dbRepresentations qi " json"
0 commit comments