AEB-labs / cruddl

Create a GraphQL API for your database, using the GraphQL SDL to model your schema.
https://aeb-labs.github.io/cruddl/
MIT License
131 stars 17 forks source link

Input validation #86

Open robross0606 opened 5 years ago

robross0606 commented 5 years ago

Does cruddl support any type of input validation and/or munging hooks or other mechanisms to ensure that mutation input is valid prior to operating against the back end database?

Yogu commented 5 years ago

No, currently, there no validation except the standard GraphQL type validation. Validation is on the roadmap for the next months, but we're not sure yet how exactly this will be implemented and if it will be available without further set-up for all cruddl users.

robross0606 commented 5 years ago

I can understand the desire to express validation with special semantics (directives, json, etc.). However, as a starting point, it would be nice to at least have a way to hook into the code to express validation logic as a callback or something like that.

To clarify, there are no means of interjecting JS code along the path between the GraphQL call and ArrangoDb. It is basically a straight-line between the GraphQL and AQL?

Yogu commented 5 years ago

cruddl does not have a plugin architecture and does not offer hooks. However, it allows you to specify your own database adapter. They have a fairly simple API: You just need to implement one method that executes a "query tree", which is a representation of the things to be done and to be queried.

It's probably not a good way to implement input validation, but if you want to alter the query tree before it's processed by the database adapter, you could extend / wrap the ArangoDBAdapter, override executeExt and alter the queryTree before passing to the original method.