Package graphql

Class ParseAndValidate


  • @PublicApi
    public class ParseAndValidate
    extends java.lang.Object
    This class allows you to parse and validate a graphql query without executing it. It will tell you if it's syntactically valid and also semantically valid according to the graphql specification and the provided schema.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static ParseAndValidateResult parse​(@NotNull ExecutionInput executionInput)
      This can be called to parse (but not validate) a graphql query.
      static ParseAndValidateResult parseAndValidate​(@NotNull GraphQLSchema graphQLSchema, @NotNull ExecutionInput executionInput)
      This can be called to parse and validate a graphql query against a schema, which is useful if you want to know if it would be acceptable for execution.
      static java.util.List<ValidationError> validate​(@NotNull GraphQLSchema graphQLSchema, @NotNull Document parsedDocument)
      This can be called to validate a parsed graphql query, with the JVM default locale.
      static java.util.List<ValidationError> validate​(@NotNull GraphQLSchema graphQLSchema, @NotNull Document parsedDocument, @NotNull java.util.function.Predicate<java.lang.Class<?>> rulePredicate)
      This can be called to validate a parsed graphql query, with the JVM default locale.
      static java.util.List<ValidationError> validate​(@NotNull GraphQLSchema graphQLSchema, @NotNull Document parsedDocument, @NotNull java.util.function.Predicate<java.lang.Class<?>> rulePredicate, @NotNull java.util.Locale locale)
      This can be called to validate a parsed graphql query.
      static java.util.List<ValidationError> validate​(@NotNull GraphQLSchema graphQLSchema, @NotNull Document parsedDocument, @NotNull java.util.Locale locale)
      This can be called to validate a parsed graphql query.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • INTERNAL_VALIDATION_PREDICATE_HINT

        public static final java.lang.String INTERNAL_VALIDATION_PREDICATE_HINT
        This GraphQLContext hint can be used to supply a Predicate to the Validator so that certain rules can be skipped. This is an internal capability that you should use at your own risk. While we intend for this to be present for some time, the validation rule class names may change, as may this mechanism.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ParseAndValidate

        public ParseAndValidate()
    • Method Detail

      • parseAndValidate

        public static ParseAndValidateResult parseAndValidate​(@NotNull
                                                              @NotNull GraphQLSchema graphQLSchema,
                                                              @NotNull
                                                              @NotNull ExecutionInput executionInput)
        This can be called to parse and validate a graphql query against a schema, which is useful if you want to know if it would be acceptable for execution.
        Parameters:
        graphQLSchema - the schema to validate against
        executionInput - the execution input containing the query
        Returns:
        a result object that indicates how this operation went
      • parse

        public static ParseAndValidateResult parse​(@NotNull
                                                   @NotNull ExecutionInput executionInput)
        This can be called to parse (but not validate) a graphql query.
        Parameters:
        executionInput - the input containing the query
        Returns:
        a result object that indicates how this operation went
      • validate

        public static java.util.List<ValidationError> validate​(@NotNull
                                                               @NotNull GraphQLSchema graphQLSchema,
                                                               @NotNull
                                                               @NotNull Document parsedDocument,
                                                               @NotNull
                                                               @NotNull java.util.Locale locale)
        This can be called to validate a parsed graphql query.
        Parameters:
        graphQLSchema - the graphql schema to validate against
        parsedDocument - the previously parsed document
        locale - the current locale
        Returns:
        a result object that indicates how this operation went
      • validate

        public static java.util.List<ValidationError> validate​(@NotNull
                                                               @NotNull GraphQLSchema graphQLSchema,
                                                               @NotNull
                                                               @NotNull Document parsedDocument)
        This can be called to validate a parsed graphql query, with the JVM default locale.
        Parameters:
        graphQLSchema - the graphql schema to validate against
        parsedDocument - the previously parsed document
        Returns:
        a result object that indicates how this operation went
      • validate

        public static java.util.List<ValidationError> validate​(@NotNull
                                                               @NotNull GraphQLSchema graphQLSchema,
                                                               @NotNull
                                                               @NotNull Document parsedDocument,
                                                               @NotNull
                                                               @NotNull java.util.function.Predicate<java.lang.Class<?>> rulePredicate,
                                                               @NotNull
                                                               @NotNull java.util.Locale locale)
        This can be called to validate a parsed graphql query.
        Parameters:
        graphQLSchema - the graphql schema to validate against
        parsedDocument - the previously parsed document
        rulePredicate - this predicate is used to decide what validation rules will be applied
        locale - the current locale
        Returns:
        a result object that indicates how this operation went
      • validate

        public static java.util.List<ValidationError> validate​(@NotNull
                                                               @NotNull GraphQLSchema graphQLSchema,
                                                               @NotNull
                                                               @NotNull Document parsedDocument,
                                                               @NotNull
                                                               @NotNull java.util.function.Predicate<java.lang.Class<?>> rulePredicate)
        This can be called to validate a parsed graphql query, with the JVM default locale.
        Parameters:
        graphQLSchema - the graphql schema to validate against
        parsedDocument - the previously parsed document
        rulePredicate - this predicate is used to decide what validation rules will be applied
        Returns:
        a result object that indicates how this operation went