lib/tapioca/dsl/compilers/graphql_mutation.rb in tapioca-0.11.8 vs lib/tapioca/dsl/compilers/graphql_mutation.rb in tapioca-0.11.9

- old
+ new

@@ -40,11 +40,11 @@ # end # ~~~ class GraphqlMutation < Compiler extend T::Sig - ConstantType = type_member { { fixed: T.class_of(GraphQL::Schema::InputObject) } } + ConstantType = type_member { { fixed: T.class_of(GraphQL::Schema::Mutation) } } sig { override.void } def decorate return unless constant.method_defined?(:resolve) @@ -57,15 +57,22 @@ arguments_by_name = arguments.to_h { |a| [a.keyword.to_s, a] } params = compile_method_parameters_to_rbi(method_def).map do |param| name = param.param.name argument = arguments_by_name.fetch(name, nil) - create_typed_param(param.param, argument ? Helpers::GraphqlTypeHelper.type_for(argument.type) : "T.untyped") + create_typed_param(param.param, argument_type(argument)) end root.create_path(constant) do |mutation| mutation.create_method("resolve", parameters: params, return_type: "T.untyped") end + end + + sig { params(argument: T.nilable(GraphQL::Schema::Argument)).returns(String) } + def argument_type(argument) + return "T.untyped" unless argument + + Helpers::GraphqlTypeHelper.type_for(argument) end class << self extend T::Sig