Generate FieldValidationInstrumentation
See original GitHub issuegraphql-java has recently implemented field level validation that is tested after the query is parsed, but before it is executed. https://github.com/graphql-java/graphql-java/issues/162
It would be really handy if this could be automatically generated using javax.validation
annotations!
I’m only just starting my own implementation so I haven’t thought it through fully, but I can see it working as follows:
- In the method that generates a
GraphQLSchema
, also generate aFieldValidationInstrumentation
- This generate would, for each GraphQL query or mutation, check the arguments
- For each argument and fields of each argument get any
javax.validation
annotations - Create a rule for each annotation. Add each rule to a
SimpleFieldValidation
- The programmer could then add the
FieldValidationInstrumentation
to the GraphQL builderGraphQL.newGraphQL(...).instrumentation(instrumentation).build()
It would also be nice to have a custom org.springframework.validation.Validator
bean that could check business logic (e.g. the email already exists in the database) but I haven’t thought about how that could be implemented yet.
There’s an example of the graphql-java validation in the method fieldValidation(), Line 161, shows an example.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:13 (6 by maintainers)
Top Results From Across the Web
Creating and Validating an Instrument - Statistics Solutions
To determine if an appropriate instrument is available, one can research literature and available databases to find something suitable to the study.
Read more >graphql.execution.instrumentation.fieldvalidation - Java
FieldAndArguments. This represents a field and its arguments that may be validated. · FieldValidationEnvironment. This contains all of the field and their ...
Read more >Validation - REDCap Docs @ QMUL
To improve data quality, use REDCap validation rules. ... One method of doing this is by employing the Validation option in the field...
Read more >Validate Dynamically Added Input fields - Stack Overflow
When the add button is clicked a new input is dynamically added. However when the form is submitted only the first input field...
Read more >HTML5 Form Validation With the “pattern” Attribute - Web Design
The validation process evaluates whether the input value is in the correct format before submitting it. For example, if we have an input...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry if this is an old thread…I’m using JavaX validation constraints in my Spring app, how should I get SPQR to pick these up? Currently I have the below Object and am trying to validate this in my Graph query:
@Matthias-Walter-Innio Answered your SO question as well.