Class: GraphQL::StaticValidation::FieldsWillMergeError
- Defined in:
- lib/graphql/static_validation/rules/fields_will_merge_error.rb
Instance Attribute Summary collapse
-
#field_name ⇒ Object
readonly
Returns the value of attribute field_name.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
Instance Method Summary collapse
-
#add_conflict(node, conflict_str) ⇒ Object
-
#code ⇒ Object
-
#conflicts ⇒ Object
-
#initialize(kind:, field_name:) ⇒ FieldsWillMergeError
constructor
A new instance of FieldsWillMergeError.
-
#message ⇒ Object
-
#path ⇒ Object
-
#to_h ⇒ Object
A hash representation of this Message.
Constructor Details
#initialize(kind:, field_name:) ⇒ FieldsWillMergeError
Returns a new instance of FieldsWillMergeError.
8 9 10 11 12 13 14 |
# File 'lib/graphql/static_validation/rules/fields_will_merge_error.rb', line 8 def initialize(kind:, field_name:) super(nil) @field_name = field_name @kind = kind @conflicts = [] end |
Instance Attribute Details
#field_name ⇒ Object (readonly)
Returns the value of attribute field_name.
5 6 7 |
# File 'lib/graphql/static_validation/rules/fields_will_merge_error.rb', line 5 def field_name @field_name end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
6 7 8 |
# File 'lib/graphql/static_validation/rules/fields_will_merge_error.rb', line 6 def kind @kind end |
Instance Method Details
#add_conflict(node, conflict_str) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/graphql/static_validation/rules/fields_will_merge_error.rb', line 28 def add_conflict(node, conflict_str) return if nodes.include?(node) @nodes << node @conflicts << conflict_str end |
#code ⇒ Object
48 49 50 |
# File 'lib/graphql/static_validation/rules/fields_will_merge_error.rb', line 48 def code "fieldConflict" end |
#conflicts ⇒ Object
24 25 26 |
# File 'lib/graphql/static_validation/rules/fields_will_merge_error.rb', line 24 def conflicts @conflicts.join(' or ') end |
#message ⇒ Object
16 17 18 |
# File 'lib/graphql/static_validation/rules/fields_will_merge_error.rb', line 16 def "Field '#{field_name}' has #{kind == :argument ? 'an' : 'a'} #{kind} conflict: #{conflicts}?" end |
#path ⇒ Object
20 21 22 |
# File 'lib/graphql/static_validation/rules/fields_will_merge_error.rb', line 20 def path [] end |
#to_h ⇒ Object
A hash representation of this Message
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/graphql/static_validation/rules/fields_will_merge_error.rb', line 36 def to_h extensions = { "code" => code, "fieldName" => field_name, "conflicts" => conflicts } super.merge({ "extensions" => extensions }) end |