Can someone sanity check this permission query for...
# prisma-whats-new
m
Can someone sanity check this permission query for me - should allow either the owner of a credit OR a user with the Admin role to (in this case) read the Credit record
Copy code
query ($node_id: ID!, $user_id: ID!) {
  SomeCreditExists(
    filter: {
      id: $node_id
	user: {
        OR: [{
          id: $user_id
        }, {
          role: Admin
        }]
      }
    })
  }
n
this does not allow every admin access, only if they are the owner 🙂
m
ahh
Better to create a separate rule?
n
if you start with SomeUserExists, you can express it in one query
m
Thanks
Something like this:
Copy code
query ($node_id: ID!, $user_id: ID!) {
  SomeUserExists(
    filter: {
      OR: [{
        id: $user_id
        role: Admin
      }, {
        id: $user_id
        jobs_some: {
        	id: $node_id
      }
      }]
      }
  	)
  }
Either the userId has admin role, or the the node belongs to the user?
n
ya! you can even pull out the user_id into the implicit AND
m
Right! DRY 🙂
Just to confirm I understood that:
Copy code
query ($user_id: ID!, $node_id: ID!) {
  SomeUserExists(
    filter: {
      id: $user_id
      OR: [{
        role: Admin
      }, {
        jobs_some: {
        	id: $node_id
      }
      }]
      }
  	)
  }
👌 1
p
Hey @nilan, I had a similar question with the
OR
filter, where I am wondering if it is possible to have multiple
OR
statements in a single query request
I created a question on the forum: https://www.graph.cool/forum/t/query-with-multiple-or-filters/1055 🙂