Package graphql
Class ParseAndValidate
java.lang.Object
graphql.ParseAndValidate
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
ThisGraphQLContext
hint can be used to supply a Predicate to the Validator so that certain rules can be skipped. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ParseAndValidateResult
parse
(@NonNull ExecutionInput executionInput) This can be called to parse (but not validate) a graphql query.static ParseAndValidateResult
parseAndValidate
(@NonNull GraphQLSchema graphQLSchema, @NonNull 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 List
<ValidationError> validate
(@NonNull GraphQLSchema graphQLSchema, @NonNull Document parsedDocument) This can be called to validate a parsed graphql query, with the JVM default locale.static List
<ValidationError> validate
(@NonNull GraphQLSchema graphQLSchema, @NonNull Document parsedDocument, @NonNull Locale locale) This can be called to validate a parsed graphql query.static List
<ValidationError> validate
(@NonNull GraphQLSchema graphQLSchema, @NonNull Document parsedDocument, @NonNull Predicate<Class<?>> rulePredicate) This can be called to validate a parsed graphql query, with the JVM default locale.static List
<ValidationError> validate
(@NonNull GraphQLSchema graphQLSchema, @NonNull Document parsedDocument, @NonNull Predicate<Class<?>> rulePredicate, @NonNull Locale locale) This can be called to validate a parsed graphql query.
-
Field Details
-
INTERNAL_VALIDATION_PREDICATE_HINT
ThisGraphQLContext
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:
-
-
Constructor Details
-
ParseAndValidate
public ParseAndValidate()
-
-
Method Details
-
parseAndValidate
public static ParseAndValidateResult parseAndValidate(@NonNull GraphQLSchema graphQLSchema, @NonNull 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 againstexecutionInput
- the execution input containing the query- Returns:
- a result object that indicates how this operation went
-
parse
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 List<ValidationError> validate(@NonNull GraphQLSchema graphQLSchema, @NonNull Document parsedDocument, @NonNull Locale locale) This can be called to validate a parsed graphql query.- Parameters:
graphQLSchema
- the graphql schema to validate againstparsedDocument
- the previously parsed documentlocale
- the current locale- Returns:
- a result object that indicates how this operation went
-
validate
public static List<ValidationError> validate(@NonNull GraphQLSchema graphQLSchema, @NonNull Document parsedDocument) This can be called to validate a parsed graphql query, with the JVM default locale.- Parameters:
graphQLSchema
- the graphql schema to validate againstparsedDocument
- the previously parsed document- Returns:
- a result object that indicates how this operation went
-
validate
public static List<ValidationError> validate(@NonNull GraphQLSchema graphQLSchema, @NonNull Document parsedDocument, @NonNull Predicate<Class<?>> rulePredicate, @NonNull Locale locale) This can be called to validate a parsed graphql query.- Parameters:
graphQLSchema
- the graphql schema to validate againstparsedDocument
- the previously parsed documentrulePredicate
- this predicate is used to decide what validation rules will be appliedlocale
- the current locale- Returns:
- a result object that indicates how this operation went
-
validate
public static List<ValidationError> validate(@NonNull GraphQLSchema graphQLSchema, @NonNull Document parsedDocument, @NonNull Predicate<Class<?>> rulePredicate) This can be called to validate a parsed graphql query, with the JVM default locale.- Parameters:
graphQLSchema
- the graphql schema to validate againstparsedDocument
- the previously parsed documentrulePredicate
- this predicate is used to decide what validation rules will be applied- Returns:
- a result object that indicates how this operation went
-