diff --git a/lib/graphql/schema/input_object.rb b/lib/graphql/schema/input_object.rb index ca0e3ee56e..adfbe70822 100644 --- a/lib/graphql/schema/input_object.rb +++ b/lib/graphql/schema/input_object.rb @@ -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 = {} diff --git a/spec/graphql/schema/input_object_spec.rb b/spec/graphql/schema/input_object_spec.rb index 35eec220f1..cabb79d50e 100644 --- a/spec/graphql/schema/input_object_spec.rb +++ b/spec/graphql/schema/input_object_spec.rb @@ -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 @@ -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