Interface OnValidationErrorStrategy


  • @PublicSpi
    public interface OnValidationErrorStrategy
    A 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_NULL is 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 OnValidationErrorStrategy RETURN_NULL
      This 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.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 via shouldContinue(java.util.List, graphql.schema.DataFetchingEnvironment).
      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.
    • 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 errors
        environment - 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 via shouldContinue(java.util.List, graphql.schema.DataFetchingEnvironment).
        Parameters:
        errors - the list errors
        environment - the environment in play
        Returns:
        an object (a sensible value would be null)