Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails-like argument validation #3207

Merged
merged 18 commits into from
Nov 16, 2020
Merged

Rails-like argument validation #3207

merged 18 commits into from
Nov 16, 2020

Conversation

rmosolgo
Copy link
Owner

@rmosolgo rmosolgo commented Oct 28, 2020

Currently, the only solution here is to implement these in application logic. That works fine, but we could provide a framework to help with it.

Fixes #799
Fixes #3164

To figure out in this PR:

  • Add validators like Rails built-in validators
  • Add general options (allow_blank, etc)
  • Get the multiple-errors situation figured out
    • I don't this this is great -- redundantly validating list items -- but it works, and we can fine-tune it later.
  • Figure out multi-argument errors (for example, one arg must be greater than the other arg, or, one of these three args must be present)
    • For now, this can be done with validates(...) on a field, using a custom validator. It could be better, like Rails, but I think it's good enough for now.
  • Make sure arguments, fields, input objects, and resolvers all have a good validation story
    • Fields accept configs via validates: or validates ...
    • Validator inheritance
    • Should args with default_value: "count" in required: { one_of: ... } combinations?
  • Should the default be to include .graphql_name or .path in error messages?
  • Add docs for built-in validators
  • Document & test the custom validator path
  • Should this work include "static" validations? (This implementation takes effect at runtime, which is the easiest and most flexible. But some validations could be run ahead-of-time.) no, we can refine this later.

@rmosolgo rmosolgo added this to the 1.12.0 milestone Oct 28, 2020
@rmosolgo rmosolgo mentioned this pull request Oct 28, 2020
33 tasks
@rmosolgo rmosolgo merged commit b2f0a8e into 1.12-dev Nov 16, 2020
@rmosolgo rmosolgo deleted the argument-validators branch November 16, 2020 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant