Class: GraphQL::StaticValidation::FieldsWillMerge::FieldDefinitionComparison
- Inherits:
-
Object
- Object
- GraphQL::StaticValidation::FieldsWillMerge::FieldDefinitionComparison
- Includes:
- Message::MessageHelper
- Defined in:
- lib/graphql/static_validation/rules/fields_will_merge.rb
Overview
Compare two field definitions, add errors to the list if there are any
Constant Summary collapse
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(name, defs, context) ⇒ FieldDefinitionComparison
constructor
A new instance of FieldDefinitionComparison.
Methods included from Message::MessageHelper
Constructor Details
#initialize(name, defs, context) ⇒ FieldDefinitionComparison
Returns a new instance of FieldDefinitionComparison.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/graphql/static_validation/rules/fields_will_merge.rb', line 69 def initialize(name, defs, context) errors = [] names = defs.map(&:name).uniq if names.length != 1 errors << ("Field '#{name}' has a field conflict: #{names.join(" or ")}?", defs.first, context: context) end args = defs.map { |defn| reduce_list(defn.arguments)}.uniq if args.length != 1 errors << ("Field '#{name}' has an argument conflict: #{args.map {|a| print_arg(a) }.join(" or ")}?", defs.first, context: context) end @errors = errors end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
68 69 70 |
# File 'lib/graphql/static_validation/rules/fields_will_merge.rb', line 68 def errors @errors end |