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

How to do validation? #47

Open
frederikhors opened this issue Dec 12, 2020 · 4 comments
Open

How to do validation? #47

frederikhors opened this issue Dec 12, 2020 · 4 comments
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@frederikhors
Copy link

Since you are fighting my own battles (gqlgen and go) can I ask you how are you dealing with the hot topic of validations?

E.g. from your example:

input ImageCreateInput {
  postId: ID!
  views: Int
  originalUrl: String
}

how to validate that e.g. views is max = 30 or originalUrl != ""?

@RichardLindhout
Copy link
Member

I don't have the use case yet of checking the input but if I require something I require it in my database / schema so
origanlUrl: String! and non-nullable database field.

We have soon a new release where it will be a lot easier to override converts/resolvers.

For the max=30 you could create your custom resolver. In the later version we will automically detect other resolver in files other than the generated one's and use the version the developer made.

But I think we need a better validation hook or something, I will make it if I have a use case for it.

For now empty fields checking in database/schema is good enough for me since I make mostly internal apps for companies and do the validation frontend

@RichardLindhout RichardLindhout added the enhancement New feature or request label Dec 12, 2020
@RichardLindhout RichardLindhout self-assigned this Dec 12, 2020
@frederikhors
Copy link
Author

For the max=30 you could create your custom resolver.

Yes, but it's not scalable. What if I need that struct embedded in another?

For now empty fields checking in database/schema is good enough for me

Yep, but for the case with empty string the user can use empty space, e.g.: " " or "-".

I wanna remove validations from frontend for RAD (rapid application development) and generate as much as possible on the server side.

@RichardLindhout
Copy link
Member

RichardLindhout commented Dec 12, 2020 via email

@RichardLindhout
Copy link
Member

It will be on my list, but after a better customization story and multiple graphql files and multiple resolvers

@RichardLindhout RichardLindhout added the question Further information is requested label Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants