Fix legacy permissions for M2O fields in GraphQL (#16430)

* Remove relation for legacy permission without allowed field

* Remove deprecated formatError and improve error handling

* Add unit test

Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
This commit is contained in:
ian
2022-11-18 00:04:56 +08:00
committed by GitHub
parent ed53673b0f
commit 0ac08da7ed
4 changed files with 64 additions and 3 deletions

View File

@@ -85,7 +85,9 @@ export function reduceSchema(
if (
relation.related_collection &&
Object.keys(allowedFieldsInCollection).includes(relation.related_collection) === false
(Object.keys(allowedFieldsInCollection).includes(relation.related_collection) === false ||
// Ignore legacy permissions with an empty fields array
allowedFieldsInCollection[relation.related_collection].length === 0)
) {
collectionsAllowed = false;
}