Class: GraphQL::Coverage::Result Private
- Inherits:
-
Object
- Object
- GraphQL::Coverage::Result
- Defined in:
- lib/graphql/coverage/result.rb
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.
Instance Method Summary collapse
- #available_fields ⇒ Object private
- #covered_fields ⇒ Object private
- #ignored_fields ⇒ Object private
-
#initialize(calls:, schema:, ignored_fields:) ⇒ Result
constructor
private
A new instance of Result.
- #match_pattern?(pat, str) ⇒ Boolean private
- #reject_ignored_fields(calls) ⇒ Object private
- #uncovered_fields ⇒ Object private
Constructor Details
#initialize(calls:, schema:, ignored_fields:) ⇒ Result
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 Result.
7 8 9 10 11 |
# File 'lib/graphql/coverage/result.rb', line 7 def initialize(calls:, schema:, ignored_fields:) @calls = calls.uniq @schema = schema @ignored_field_patterns = ignored_fields end |
Instance Method Details
#available_fields ⇒ Object
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.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/graphql/coverage/result.rb', line 25 def available_fields # @type var target_types: Array[singleton(GraphQL::Schema::Object)] target_types = _ = @schema.types.select { |name, klass| klass < GraphQL::Schema::Object && !name.start_with?('__') }.values target_types.flat_map do |klass| klass.fields.values.map do |field| Call.from_graphql_object(field: field, result_type: nil) end end end |
#covered_fields ⇒ Object
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.
13 14 15 |
# File 'lib/graphql/coverage/result.rb', line 13 def covered_fields @calls end |
#ignored_fields ⇒ Object
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.
21 22 23 |
# File 'lib/graphql/coverage/result.rb', line 21 def ignored_fields available_fields - uncovered_fields - @calls end |
#match_pattern?(pat, str) ⇒ 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.
46 47 48 49 50 51 52 |
# File 'lib/graphql/coverage/result.rb', line 46 def match_pattern?(pat, str) if pat == '*' true else pat == str end end |
#reject_ignored_fields(calls) ⇒ Object
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.
36 37 38 39 40 41 42 43 44 |
# File 'lib/graphql/coverage/result.rb', line 36 def reject_ignored_fields(calls) calls.reject do |call| @ignored_field_patterns.any? do |ignored_field| type = __skip__ = ignored_field[:type] || ignored_field['type'] field = __skip__ = ignored_field[:field] || ignored_field['field'] match_pattern?(type, call.type) && match_pattern?(field, call.field) end end end |
#uncovered_fields ⇒ Object
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.
17 18 19 |
# File 'lib/graphql/coverage/result.rb', line 17 def uncovered_fields @uncovered_fields ||= reject_ignored_fields(available_fields - @calls) end |