How do I make a query require authentication and return an error if the user is not logged in?

Currently, the query returns nothing when there is no user logged in. But I would like it to return an authentication error.
4 Replies
sevenseacat
sevenseacat•3w ago
you might be looking for the access_type option on a policy - for a read action, if the policy fails it will return an unauthorized error instead of applying a filter
JVMartyns
JVMartynsOP•3w ago
Changing this option to :strict causes the query to return a forbidden error 🤔. I wish it were unauthenticated, but this is already better than how it was before.
sevenseacat
sevenseacat•3w ago
ah forbidden not unauthorized, my bad making it unauthenticated could be hard to do, given a policy can have anything in it, not just verifying that an actor is present
ZachDaniel
ZachDaniel•3w ago
We don't support custom error messages from policies yet I'd like to though You could add a change or preparation to your action and add a custom error Instead of using policies

Did you find this page helpful?