Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authorization validate argument should also handle a single (non-array) entry #4534

Open
mjfwebb opened this issue Jan 19, 2024 · 2 comments
Labels
bug report Something isn't working confirmed Confirmed bug
Projects

Comments

@mjfwebb
Copy link
Contributor

mjfwebb commented Jan 19, 2024

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) 
@mjfwebb mjfwebb added the bug report Something isn't working label Jan 19, 2024
@neo4j-team-graphql neo4j-team-graphql added this to Bug reports in Bug Triage Jan 19, 2024
@neo4j-team-graphql
Copy link
Collaborator

Many thanks for raising this bug report @mjfwebb. 🐛 We will now attempt to reproduce the bug based on the steps you have provided.

Please ensure that you've provided the necessary information for a minimal reproduction, including but not limited to:

  • Type definitions
  • Resolvers
  • Query and/or Mutation (or multiple) needed to reproduce

If you have a support agreement with Neo4j, please link this GitHub issue to a new or existing Zendesk ticket.

Thanks again! 🙏

@mjfwebb mjfwebb moved this from Bug reports to Confirmed in Bug Triage Jan 23, 2024
@neo4j-team-graphql neo4j-team-graphql added the confirmed Confirmed bug label Jan 23, 2024
@neo4j-team-graphql
Copy link
Collaborator

We've been able to confirm this bug using the steps to reproduce that you provided - many thanks @mjfwebb! 🙏 We will now prioritise the bug and address it appropriately.

@mjfwebb mjfwebb moved this from Confirmed to Low priority in Bug Triage Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Something isn't working confirmed Confirmed bug
Projects
Bug Triage
Low priority
Development

No branches or pull requests

2 participants