swarthout / feathers-apollo

Feathers and Apollo Server Sample Project
MIT License
176 stars 20 forks source link

Pre-processing hooks: can they be used for validation? #13

Closed idibidiart closed 7 years ago

idibidiart commented 7 years ago

With Feathers, it looks like we can have pre-processing hooks for mutations? If so, can they be used for validating user input on the server (and avoiding duplication of logic on client?) In that case, if the data is invalid, can the mutation be avoided/ignored?

p.s. there is a lot of stuff that could be added to this great demo (custom events, socket.io, validation, etc) to explore all the features that Feathers brings to GQL. I hope to be able to contribute, but currently trying to understand what is possible out of the box.

Thanks once again!

idibidiart commented 7 years ago

btw, by 'validation' I mean the business logic kind, not simply validating that a given param is a string. Business logic should go into services and I'm wondering if Feathers hooks could be used to run some business logic and based on that decide whether or not to invoke the mutation. Or do we put that logic into the resolvers?

idibidiart commented 7 years ago

N/M. I realized that business-logic-driven validation needs to be in the GraphQL resolvers (and generic validation can be in the UI component) The Feathers services are generic and so business logic resides in the resolvers.