redwoodjs / redwood

The App Framework for Startups
https://redwoodjs.com
MIT License
17.23k stars 989 forks source link

[Docs]: Confusion around Validator Directives vs. Service Validation #8996

Open JoshFerge opened 1 year ago

JoshFerge commented 1 year ago

Summary and description

my docs version: Redwood 6.0

I'd like to have my services validate that the logged in user can only edit the data that they own. I'm trying to figure out in the docs the most ergonomic way to do this.

On this page: https://redwoodjs.com/docs/directives#when-should-i-use-a-redwood-directive

Screenshot 2023-07-30 at 5 40 04 PM

the docs say to do the check in your service instead.

On the service docs: https://redwoodjs.com/docs/services#service-validations it says you should do this in a validator directive. Is there a contradiction here, or what am I missing?

Screenshot 2023-07-30 at 5 40 24 PM

Are you interested in working on this?

Tobbe commented 1 year ago

I agree. That does sound contradictory 🧐 I think the Service Validations docs are wrong, and personally I'd implement the check you're asking about inside my services. Especially as you then also get the check whenever you call your services from other places and not just directly from graphql.

But @dthyresson is our resident expert on these things, so hopefully he can provide some guidance here 🗺️