graphql-assert-transformer
graphql-assert-transformer copied to clipboard
Assertion on ID only happen when value provided
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
Also for type String it happen only when value is provided, so length does not check in null
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!
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.