Class: GraphQL::Query::ValidationPipeline Private

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/query/validation_pipeline.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Contain the validation pipeline and expose the results.

  1. Checks in #initialize:
    • Rescue a ParseError, halt if there is one
    • Check for selected operation, halt if not found
  2. Validate the AST, halt if errors
  3. Validate the variables, halt if errors
  4. Run query analyzers, halt if errors

#valid? is false if any of the above checks halted the pipeline.

Instance Method Summary collapse

Constructor Details

#initialize(query:, validate:, parse_error:, operation_name_error:, max_depth:, max_complexity:) ⇒ ValidationPipeline

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ValidationPipeline.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/graphql/query/validation_pipeline.rb', line 17

def initialize(query:, validate:, parse_error:, operation_name_error:, max_depth:, max_complexity:)
  @validation_errors = []
  @analysis_errors = []
  @internal_representation = nil
  @validate = validate
  @parse_error = parse_error
  @operation_name_error = operation_name_error
  @query = query
  @schema = query.schema
  @max_depth = max_depth
  @max_complexity = max_complexity

  @has_validated = false
end

Instance Method Details

#analysis_errorsArray<GraphQL::AnalysisError>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Errors for this particular query run (eg, exceeds max complexity).

Returns:



39
40
41
42
# File 'lib/graphql/query/validation_pipeline.rb', line 39

def analysis_errors
  ensure_has_validated
  @analysis_errors
end

#analyzersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



56
57
58
59
# File 'lib/graphql/query/validation_pipeline.rb', line 56

def analyzers
  ensure_has_validated
  @query_analyzers
end

#internal_representationHash<String, nil => GraphQL::InternalRepresentation::Node] Operation name -

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Irep node pairs.

Returns:



51
52
53
54
# File 'lib/graphql/query/validation_pipeline.rb', line 51

def internal_representation
  ensure_has_validated
  @internal_representation
end

#valid?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns does this query have errors that should prevent it from running?.

Returns:

  • (Boolean)

    does this query have errors that should prevent it from running?



33
34
35
36
# File 'lib/graphql/query/validation_pipeline.rb', line 33

def valid?
  ensure_has_validated
  @valid
end

#validation_errorsArray<GraphQL::StaticValidation::Message>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Static validation errors for the query string.

Returns:



45
46
47
48
# File 'lib/graphql/query/validation_pipeline.rb', line 45

def validation_errors
  ensure_has_validated
  @validation_errors
end