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

Use directive to validate input object fields #297

Closed
almyy opened this issue Jul 31, 2019 · 3 comments
Closed

Use directive to validate input object fields #297

almyy opened this issue Jul 31, 2019 · 3 comments
Labels

Comments

@almyy
Copy link
Contributor

almyy commented Jul 31, 2019

I'm trying to create a directive that should, on an input object field, validate an input value at runtime. For example:

input Foo {
    bar: String @notBlank
}

I've tried to follow the same idea as the examples here, but there's no datafetcher to wrap, since we don't have any fieldsContainer or fieldDefinition.

Is this currently possible, and if so, could you point me in the right direction?

@lilianchiassai
Copy link

You want to use graphql-java-extended-validation, that is not yet perfectly compatible with graphql-java-kickstart.
You will need to overwrite the Graphql configuration (Cliedeman published an example here https://gist.github.com/cliedeman/21b0c943f6c5138c3a68c070cf1fb847).

You will then run into a few problems I ran into in the last few days (both have workarounds):

@vojtapol
Copy link
Member

vojtapol commented Feb 4, 2020

Please comment on this issue if the question has not been answered.

@vojtapol vojtapol closed this as completed Feb 4, 2020
@brendamckenne
Copy link

An issue is open at
graphql-java/graphql-java-extended-validation#12

actually its an issue with @notblank in that extended validation library

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

4 participants