fix: Add a hint and clarification to the no relationship found error (#1858)

This commit is contained in:
laurenceisla
2021-05-31 12:15:31 -05:00
committed by GitHub
parent 88a481da8a
commit 1b12b112a1
3 changed files with 15 additions and 6 deletions
+2 -1
View File
@@ -86,7 +86,8 @@ instance JSON.ToJSON ApiRequestError where
toJSON InvalidRange = JSON.object [
"message" .= ("HTTP Range error" :: Text)]
toJSON (NoRelBetween parent child) = JSON.object [
"message" .= ("Could not find foreign keys between these entities. No relationship found between " <> parent <> " and " <> child :: Text)]
"hint" .= ("If a new foreign key between these entities was created in the database, try reloading the schema cache." :: Text),
"message" .= ("Could not find a relationship between " <> parent <> " and " <> child <> " in the schema cache" :: Text)]
toJSON (AmbiguousRelBetween parent child rels) = JSON.object [
"hint" .= ("By following the 'details' key, disambiguate the request by changing the url to /origin?select=relationship(*) or /origin?select=target!relationship(*)" :: Text),
"message" .= ("More than one relationship was found for " <> parent <> " and " <> child :: Text),