Skip to content
This repository was archived by the owner on Feb 10, 2019. It is now read-only.

Rules on custom fields #27

Closed
chrissm79 opened this issue Feb 10, 2016 · 2 comments
Closed

Rules on custom fields #27

chrissm79 opened this issue Feb 10, 2016 · 2 comments

Comments

@chrissm79
Copy link
Contributor

This is more of an suggestion, but I have a custom field that requires arguments and I'd like to use the built-in validation. It only took me a few minutes to realize that a Mutation is nothing more than of Field that has rules applied. I simply switched my Field to extend a Mutation instead and everything works fine, but I'm wondering if that logic could be placed in the Field and still have the Mutation type extend it just for naming purposes.

Alternatively, maybe the logic could be put into a trait which mutations use and the user can choose to add the trait to have validation run on a custom field's arguments (something like ShouldBeValidated).

Thanks!

@dmongeau
Copy link
Member

I've implemented your suggestion (validation as a trait) in 1.0.0. Thanks!

@tremby
Copy link

tremby commented Aug 8, 2017

For any who might come across this later:

  1. Add use Folklore\GraphQL\Support\Traits\ShouldValidate; to the top of your Query class file
  2. Add use ShouldValidate; inside the class.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants