If only 1 Business node doesn't have the user, i g...
# prisma-whats-new
k
If only 1 Business node doesn't have the user, i got null. Instead of having just the user's business.
n
@kmeillet hey you can use the filter system to avoid querying a node that you can't access
typically you would use the
Copy code
query { user { id businesses { id } } }
query
k
But any people can call allBussineses and view all of them
n
no, that's what the permission system allows you to prevent 🙂
k
Yes, that why i've tried to make this permission query on "Business" model : query ($node_id: ID!, $user_id: ID!) { SomeBusinessExists(filter: { id: $node_id, users_some: { id: $user_id } }) } But when an user call AllBusinesses now, he can't view anything : "data": null (instead of just the user business)
n
Yep. You need to avoid querying a business that the user can't access, using the filter system.
k
i think i don't understand the permission system ^^
ah
ok
n
in your case, you require a connection between the logged in user and the business, right?
k
Yes
query ($userId: ID!) { allBusinesses(filter: { users_some: { id: $userId }}) { id, name } }
should works
n
the
user
query allows you to query the businesses connected to the logged in user without using a filter
yes, exactly
k
or i can traverse user yes
thx 🙂
n
👍
k
So if i'm right, when i'm calling a query, all result Nodes is passed into Permission Query, and if just one or more Nodes doesn't meet the requirement, the query result is null and you got 0 Nodes. So, instead, just make query to satisfy permission, and get what do you want.
n
That's a good summary 👍
🦜 1