Fix embedded filter silently getting ignored (#2133)

When the embedded resource is not included in the request
This commit is contained in:
Steve Chavez
2022-01-24 17:52:27 -05:00
committed by GitHub
parent fae1e168a7
commit c7cadcd776
5 changed files with 80 additions and 49 deletions
+4
View File
@@ -68,6 +68,7 @@ instance PgrstError ApiRequestError where
status NoRpc{} = HTTP.status404
status (UnacceptableSchema _) = HTTP.status406
status (ContentTypeError _) = HTTP.status415
status (NotEmbedded _) = HTTP.status400
headers _ = [ContentType.toHeader CTApplicationJSON]
@@ -111,6 +112,9 @@ instance JSON.ToJSON ApiRequestError where
"message" .= ("The schema must be one of the following: " <> T.intercalate ", " schemas)]
toJSON (ContentTypeError cts) = JSON.object [
"message" .= ("None of these Content-Types are available: " <> T.intercalate ", " (map T.decodeUtf8 cts))]
toJSON (NotEmbedded resource) = JSON.object [
"hint" .= ("Verify that '" <> resource <> "' is included in the 'select' query parameter." :: Text),
"message" .= ("Cannot apply filter because '" <> resource <> "' is not an embedded resource in this request" :: Text)]
compressedRel :: Relationship -> JSON.Value
compressedRel Relationship{..} =