Class: GraphQL::Doctor::Correlation::Correlator
- Inherits:
-
Object
- Object
- GraphQL::Doctor::Correlation::Correlator
- Defined in:
- lib/graphql/doctor/correlation/correlator.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Instance Method Summary collapse
-
#initialize(source_index, runtime_ir) ⇒ Correlator
constructor
A new instance of Correlator.
- #mapped_field_ratio ⇒ Object
- #matched ⇒ Object
- #runtime_only ⇒ Object
- #source_only ⇒ Object
Constructor Details
#initialize(source_index, runtime_ir) ⇒ Correlator
Returns a new instance of Correlator.
11 12 13 14 15 |
# File 'lib/graphql/doctor/correlation/correlator.rb', line 11 def initialize(source_index, runtime_ir) @source_index = source_index @runtime_fields = runtime_ir.fetch("types", []).flat_map { |type| type.fetch("fields", []) } @fields = correlate end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
9 10 11 |
# File 'lib/graphql/doctor/correlation/correlator.rb', line 9 def fields @fields end |
Instance Method Details
#mapped_field_ratio ⇒ Object
29 30 31 32 |
# File 'lib/graphql/doctor/correlation/correlator.rb', line 29 def mapped_field_ratio denominator = matched.length + runtime_only.length denominator.zero? ? 1.0 : matched.length.fdiv(denominator) end |
#matched ⇒ Object
17 18 19 |
# File 'lib/graphql/doctor/correlation/correlator.rb', line 17 def matched fields.select { |field| field.status == :matched } end |
#runtime_only ⇒ Object
21 22 23 |
# File 'lib/graphql/doctor/correlation/correlator.rb', line 21 def runtime_only fields.select { |field| field.status == :runtime_only } end |
#source_only ⇒ Object
25 26 27 |
# File 'lib/graphql/doctor/correlation/correlator.rb', line 25 def source_only fields.select { |field| field.status == :source_only } end |