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.
- #message ⇒ Object
Attributes inherited from Error
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.
- #path ⇒ Object
-
#to_h ⇒ Object
A hash representation of this Message.
Constructor Details
permalink #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
permalink #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 |
permalink #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 |
permalink #message ⇒ Object
16 17 18 |
# File 'lib/graphql/static_validation/rules/fields_will_merge_error.rb', line 16 def @message || "Field '#{field_name}' has #{kind == :argument ? 'an' : 'a'} #{kind} conflict: #{conflicts}?" end |
Instance Method Details
permalink #add_conflict(node, conflict_str) ⇒ Object
[View source]
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/graphql/static_validation/rules/fields_will_merge_error.rb', line 30 def add_conflict(node, conflict_str) # Can't use `.include?` here because AST nodes implement `#==` # based on string value, not including location. But sometimes, # identical nodes conflict because of their differing return types. if nodes.any? { |n| n == node && n.line == node.line && n.col == node.col } # already have an error for this node return end @nodes << node @conflicts << conflict_str end |
permalink #code ⇒ Object
[View source]
56 57 58 |
# File 'lib/graphql/static_validation/rules/fields_will_merge_error.rb', line 56 def code "fieldConflict" end |
permalink #conflicts ⇒ Object
[View source]
26 27 28 |
# File 'lib/graphql/static_validation/rules/fields_will_merge_error.rb', line 26 def conflicts @conflicts.join(' or ') end |
permalink #path ⇒ Object
[View source]
22 23 24 |
# File 'lib/graphql/static_validation/rules/fields_will_merge_error.rb', line 22 def path [] end |
permalink #to_h ⇒ Object
A hash representation of this Message
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/graphql/static_validation/rules/fields_will_merge_error.rb', line 44 def to_h extensions = { "code" => code, "fieldName" => field_name, "conflicts" => conflicts } super.merge({ "extensions" => extensions }) end |