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

Can't validate request #68

Open
itayAmza opened this issue Sep 21, 2021 · 1 comment
Open

Can't validate request #68

itayAmza opened this issue Sep 21, 2021 · 1 comment
Labels

Comments

@itayAmza
Copy link

Following Vapor's Validation API, I'm not really sure what is the right way to validate arguments in Graffiti.
I've made the arguments struct conform to Validatable but since I cannot call validate before it's being decode, I'm always getting 'field is required' error.

@NeedleInAJayStack
Copy link
Member

Hey @itayAmza, I don't think there's a good way to call validate(_ decoder: Decoder) before decode, since fields automatically define the decode block here:

let a = try MapDecoder().decode(Arguments.self, from: arguments)

I think you have a few options:

  1. Code your own after-the-fact validation and place the logic in your resolver function, throwing errors when it fails
  2. Drop down into https://github.com/GraphQLSwift/GraphQL, where you have full control over argument decoding in the resolvers

Hope that helps!

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

No branches or pull requests

2 participants