Class SimpleFieldValidation
java.lang.Object
graphql.execution.instrumentation.fieldvalidation.SimpleFieldValidation
- All Implemented Interfaces:
FieldValidation
This very simple field validation will run the supplied function for a given field path and if it returns an error
it will be added to the list of problems.
Use
addRule(ResultPath, java.util.function.BiFunction)
to supply the rule callbacks where
you implement your specific business logic-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddRule
(ResultPath fieldPath, BiFunction<FieldAndArguments, FieldValidationEnvironment, Optional<GraphQLError>> rule) Adds the rule against the field address path.validateFields
(FieldValidationEnvironment validationEnvironment) This is called to validate the fields and their arguments
-
Constructor Details
-
SimpleFieldValidation
public SimpleFieldValidation()
-
-
Method Details
-
addRule
public SimpleFieldValidation addRule(ResultPath fieldPath, BiFunction<FieldAndArguments, FieldValidationEnvironment, Optional<GraphQLError>> rule) Adds the rule against the field address path. If the rule returns an error, it will be added to the list of errors- Parameters:
fieldPath
- the path to the fieldrule
- the rule function- Returns:
- this validator
-
validateFields
Description copied from interface:FieldValidation
This is called to validate the fields and their arguments- Specified by:
validateFields
in interfaceFieldValidation
- Parameters:
validationEnvironment
- the validation environment- Returns:
- a list of errors. If this is non empty then the query will not execute.
-