@@ -224,6 +224,77 @@ def resolve(min:, max:, other:, proc:); end
224224 assert_equal ( expected , rbi_for ( :CreateComment ) )
225225 end
226226
227+ it "generates correct RBI for a list argument with a prepare method returning the same list type" do
228+ add_ruby_file ( "create_comment.rb" , <<~RUBY )
229+ class CreateComment < GraphQL::Schema::Mutation
230+ extend T::Sig
231+
232+ class << self
233+ extend T::Sig
234+ sig { params(tags: T::Array[String], _context: T.untyped).returns(T::Array[String]) }
235+ def prepare_tags(tags, _context)
236+ tags.map(&:downcase)
237+ end
238+ end
239+
240+ argument :tags, [String], "Tags for the comment", prepare: :prepare_tags
241+
242+ def resolve(tags:)
243+ # ...
244+ end
245+ end
246+ RUBY
247+
248+ expected = <<~RBI
249+ # typed: strong
250+
251+ class CreateComment
252+ sig { params(tags: T::Array[::String]).returns(T.untyped) }
253+ def resolve(tags:); end
254+ end
255+ RBI
256+
257+ assert_equal ( expected , rbi_for ( :CreateComment ) )
258+ end
259+
260+ it "generates correct RBI for a list argument with a prepare method that has no valid return type" do
261+ add_ruby_file ( "create_comment.rb" , <<~RUBY )
262+ class CreateComment < GraphQL::Schema::Mutation
263+ extend T::Sig
264+
265+ class << self
266+ extend T::Sig
267+ sig { params(tags: T::Array[String], _context: T.untyped).void }
268+ def prepare_tags_void(tags, _context)
269+ tags.map(&:downcase)
270+ end
271+
272+ def prepare_tags_untyped(tags, _context)
273+ tags.map(&:downcase)
274+ end
275+ end
276+
277+ argument :tags, [String], "Tags for the comment", prepare: :prepare_tags_void
278+ argument :other_tags, [String], "Other tags for the comment", prepare: :prepare_tags_untyped
279+
280+ def resolve(tags:, other_tags:)
281+ # ...
282+ end
283+ end
284+ RUBY
285+
286+ expected = <<~RBI
287+ # typed: strong
288+
289+ class CreateComment
290+ sig { params(tags: T::Array[::String], other_tags: T::Array[::String]).returns(T.untyped) }
291+ def resolve(tags:, other_tags:); end
292+ end
293+ RBI
294+
295+ assert_equal ( expected , rbi_for ( :CreateComment ) )
296+ end
297+
227298 it "generates correct RBI arguments with a prepare method on the argument class" do
228299 add_ruby_file ( "create_comment.rb" , <<~RUBY )
229300 class CommentInput < GraphQL::Schema::InputObject
0 commit comments