Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/graphql/schema/input_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ def coerce_input(value, ctx)
# It's funny to think of a _result_ of an input object.
# This is used for rendering the default value in introspection responses.
def coerce_result(value, ctx)
# Allow the application to provide values as :symbols, and convert them to the strings
value = value.reduce({}) { |memo, (k, v)| memo[k.to_s] = v; memo }
# Allow the application to provide values as :snake_symbols, and convert them to the camelStrings
value = value.reduce({}) { |memo, (k, v)| memo[Member::BuildType.camelize(k.to_s)] = v; memo }

result = {}

Expand Down
12 changes: 6 additions & 6 deletions spec/graphql/schema/input_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -493,18 +493,18 @@ def self.resolve_type(type, obj, ctx)
it "introspects in GraphQL language with enums" do
class InputDefaultSchema < GraphQL::Schema
class Letter < GraphQL::Schema::Enum
value "A"
value "B"
value "A", value: 1
value "B", value: 2
end

class InputObj < GraphQL::Schema::InputObject
argument :a, Letter, required: false
argument :b, Letter, required: false
argument :arg_a, Letter, required: false
argument :arg_b, Letter, required: false
end

class Query < GraphQL::Schema::Object
field :i, Int, null: true do
argument :arg, InputObj, required: false, default_value: { a: "A", b: "B" }
argument :arg, InputObj, required: false, default_value: { arg_a: 1, arg_b: 2 }
end
end

Expand All @@ -524,7 +524,7 @@ class Query < GraphQL::Schema::Object
}
}
"
assert_equal "{a: A, b: B}", res["data"]["__type"]["fields"].first["args"].first["defaultValue"]
assert_equal "{argA: A, argB: B}", res["data"]["__type"]["fields"].first["args"].first["defaultValue"]
end
end

Expand Down