graphql
graphql copied to clipboard
Authorization validate argument should also handle a single (non-array) entry
The library is throwing an error if the validate argument is not an array.
We should be able to handle both an array of arguments and a single non-array argument:
validate: { where: { jwt: { roles_INCLUDES: "admin" } } }
validate: [{ where: { jwt: { roles_INCLUDES: "admin" } } }]
Currently, it only accepts the latter where the argument is an array. With the former, the following error is thrown by the library:
TypeError: validate?.map is not a function
35 | };
36 | const filterRules = filter?.map((rule) => new AuthorizationFilterRule(rule as AuthorizationFilterRuleConstructor));
> 37 | const validateRules = validate?.map(
| ^
38 | (rule) => new AuthorizationValidateRule(rule as AuthorizationValidateRuleConstructor)
39 | );
40 |
at parseAuthorizationAnnotation (packages/graphql/src/schema-model/parser/annotations-parser/authorization-annotation.ts:37:37)