Currently I am running a development branch: 243a336d1.
There are a few things I am trying to solve with auth rules:
- Show active nodes unless a parameter is passed in then show active and inactive. I have read that boolean parameters are not supported yet, any word on when this will be updated? So for now I am using a string
- Filter users via the selectedRegions, need to pass in an array paramater.
- Filter users, pass in an array of ids to be used in a query. Or can I pass in an array of strings to and do a contains. e.g. a rule like: {$PERMISSIONS: {eq: “USERS”}} where $PERMISSIONS = [“USERS”, “REGIONS”]
Here is my attempts at solving point one and two, I am having issues with the REGIONS paramater as I dont think I can pass arrays.
type User @auth( query: { rule: "{ and: [{ or: [{$SHOWINACTIVE: { eq: \"true\" }}, {queryUser(filter: {active: true}) { id} }]}, {query($REGIONS: [ID!]) {queryUser { selectedRegions(filters: {id: $REGIONS}) { id}}}}]}" } ) {
username: String @search(by: [regexp])
firstName: String @search(by: [regexp])
lastName: String @search(by: [regexp])
active: Boolean @search
permissions: [Permission] @hasInverse(field: users)
selectedRegions: [Region] @hasInverse(field: users)
}
type Permission {
name: String @search(by: [regexp])
active: Boolean @search
users: [User] @hasInverse(field: permissions)
}
type Region {
name: String @search(by: [regexp])
active: Boolean @search
users: [User] @hasInverse(field: selectedRegions)
}