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

Assertion on ID only happen when value provided #4

Open
mjza opened this issue Mar 30, 2021 · 3 comments
Open

Assertion on ID only happen when value provided #4

mjza opened this issue Mar 30, 2021 · 3 comments

Comments

@mjza
Copy link

mjza commented Mar 30, 2021

I need to check the value has been provided for a Id, but I cannot define it as mandatory to be able to define auth:

categoryId: ID
    @assert(condition: ".length() > 1 && .matches(\"^\\w+$\")")
    @auth(
      rules: [
        { allow: owner, provider: userPools, operations: [create, update, read] }
        {
          allow: groups
          groups: ["Supers", "Admins", "Employees"]
          provider: userPools
          operations: [create, update, read]
        }
      ]
    )

But the assertion only file when user provides something, it means null is acceptable

@mjza
Copy link
Author

mjza commented Mar 30, 2021

Also for type String it happen only when value is provided, so length does not check in null

@mjza
Copy link
Author

mjza commented Mar 30, 2021

How can I check for not null?

categoryId: ID
    @assert(condition: ". != null")
    @auth(
      rules: [
        { allow: owner, provider: userPools, operations: [create, update, read] }
        {
          allow: groups
          groups: ["Supers", "Admins", "Employees"]
          provider: userPools
          operations: [create, update, read]
        }
      ]
    )

Does not work!

@PatrykMilewski
Copy link

You just need to require it in GraphQL:

categoryId: ID!
    @auth(
      rules: [
        { allow: owner, provider: userPools, operations: [create, update, read] }
        {
          allow: groups
          groups: ["Supers", "Admins", "Employees"]
          provider: userPools
          operations: [create, update, read]
        }
      ]
    )

using exclamation mark after the field type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants