Package graphql.validation.rules
Interface OnValidationErrorStrategy
-
@PublicSpi public interface OnValidationErrorStrategyA callback that indicates whether to continue the data fetching after validation errors are detected and what value should be returned if it decides to not continue.RETURN_NULLis a common strategy to use, that is return null as the value for an invalid field
-
-
Field Summary
Fields Modifier and Type Field Description static OnValidationErrorStrategyRETURN_NULLThis strategy will prevent the current data fetch and return null as a value along with the errors
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.ObjectonErrorValue(java.util.List<graphql.GraphQLError> errors, graphql.schema.DataFetchingEnvironment environment)This will be called to generate a value that should be returned if we decide NOT to continue viashouldContinue(java.util.List, graphql.schema.DataFetchingEnvironment).booleanshouldContinue(java.util.List<graphql.GraphQLError> errors, graphql.schema.DataFetchingEnvironment environment)This is called when there are validation errors present and it can decide whether to continue the current data fetch (and hence return null) or whether it should in fact continue on anyway.
-
-
-
Field Detail
-
RETURN_NULL
static final OnValidationErrorStrategy RETURN_NULL
This strategy will prevent the current data fetch and return null as a value along with the errors
-
-
Method Detail
-
shouldContinue
boolean shouldContinue(java.util.List<graphql.GraphQLError> errors, graphql.schema.DataFetchingEnvironment environment)This is called when there are validation errors present and it can decide whether to continue the current data fetch (and hence return null) or whether it should in fact continue on anyway.- Parameters:
errors- the list errorsenvironment- the environment in play- Returns:
- true if the current data fetch should continue
-
onErrorValue
java.lang.Object onErrorValue(java.util.List<graphql.GraphQLError> errors, graphql.schema.DataFetchingEnvironment environment)This will be called to generate a value that should be returned if we decide NOT to continue viashouldContinue(java.util.List, graphql.schema.DataFetchingEnvironment).- Parameters:
errors- the list errorsenvironment- the environment in play- Returns:
- an object (a sensible value would be null)
-
-