Skip to content

Commit dc8fe36

Browse files
committed
Fix args compatibility in 1.9.13
1 parent 902befe commit dc8fe36

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

lib/graphql/query/arguments.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ def to_kwargs
118118
ruby_kwargs
119119
end
120120

121+
alias :to_hash :to_kwargs
122+
121123
private
122124

123125
class ArgumentValue

spec/graphql/schema/field_spec.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,4 +316,37 @@
316316
assert_equal :my_field, field.original_name
317317
end
318318
end
319+
320+
describe "generated default" do
321+
class TestSchema < GraphQL::Schema
322+
class BaseField < GraphQL::Schema::Field
323+
def resolve_field(obj, args, ctx)
324+
resolve(obj, args, ctx)
325+
end
326+
end
327+
328+
class Company < GraphQL::Schema::Object
329+
field :id, ID, null: false
330+
end
331+
332+
class Query < GraphQL::Schema::Object
333+
field_class BaseField
334+
335+
field :company, Company, null: true do
336+
argument :id, ID, required: true
337+
end
338+
339+
def company(id:)
340+
OpenStruct.new(id: id)
341+
end
342+
end
343+
344+
query(Query)
345+
end
346+
347+
it "works" do
348+
res = TestSchema.execute("{ company(id: \"1\") { id } }")
349+
assert_equal "1", res["data"]["company"]["id"]
350+
end
351+
end
319352
end

0 commit comments

Comments
 (0)