lib/graphql_rails/attributes/attribute.rb in graphql_rails-1.0.0 vs lib/graphql_rails/attributes/attribute.rb in graphql_rails-1.1.0
- old
+ new
@@ -11,18 +11,21 @@
include Attributable
include InputConfigurable
attr_reader :attributes
- def initialize(name, type = nil, description: nil, property: name, required: nil)
+ # rubocop:disable Metrics/ParameterLists
+ def initialize(name, type = nil, description: nil, property: name, required: nil, options: {})
@initial_type = type
@initial_name = name
+ @options = options
@description = description
@property = property.to_s
@required = required
@attributes ||= {}
end
+ # rubocop:enable Metrics/ParameterLists
def type(new_type = nil)
return @initial_type if new_type.nil?
@initial_type = new_type
@@ -41,22 +44,33 @@
@property = new_property.to_s
self
end
+ def options(new_options = {})
+ return @options if new_options.blank?
+
+ @options = new_options
+ self
+ end
+
def field_args
[
field_name,
type_parser.type_arg,
- *description,
- {
- method: property.to_sym,
- null: optional?
- }
+ *description
]
end
+ def field_options
+ {
+ method: property.to_sym,
+ null: optional?,
+ camelize: camelize?
+ }
+ end
+
def argument_args
[
field_name,
type_parser.type_arg,
{
@@ -67,8 +81,14 @@
end
protected
attr_reader :initial_type, :initial_name
+
+ private
+
+ def camelize?
+ options[:input_format] != :original && options[:attribute_name_format] != :original
+ end
end
end
end