lib/tapioca/dsl/compilers/graphql_input_object.rb in tapioca-0.10.5 vs lib/tapioca/dsl/compilers/graphql_input_object.rb in tapioca-0.11.0

- old
+ new

@@ -43,18 +43,38 @@ ConstantType = type_member { { fixed: T.class_of(GraphQL::Schema::InputObject) } } sig { override.void } def decorate - arguments = constant.all_argument_definitions + # Skip methods explicitly defined in code + arguments = constant.all_argument_definitions.select do |argument| + method_defined_by_graphql?(argument.keyword.to_s) + end + return if arguments.empty? root.create_path(constant) do |input_object| arguments.each do |argument| name = argument.keyword.to_s input_object.create_method(name, return_type: Helpers::GraphqlTypeHelper.type_for(argument.type)) end end + end + + private + + sig { returns(T.nilable(String)) } + def graphql_input_object_argument_source_file + @graphql_input_object_argument_source_file ||= T.let( + GraphQL::Schema::InputObject.method(:argument).source_location&.first, + T.nilable(String), + ) + end + + sig { params(method_name: String).returns(T::Boolean) } + def method_defined_by_graphql?(method_name) + method_file = constant.instance_method(method_name).source_location&.first + !!(method_file && graphql_input_object_argument_source_file == method_file) end class << self extend T::Sig