Skip to content

Commit

Permalink
Handle the list case
Browse files Browse the repository at this point in the history
  • Loading branch information
such committed Jul 10, 2023
1 parent 344fe62 commit e16efa7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/tapioca/dsl/compilers/graphql_mutation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ def argument_type(argument)
return "T.untyped" unless argument

argument_type = if argument.loads
type = argument.type.list? ? GraphQL::Schema::List.new(argument.loads) : argument.loads
if GraphQL::Schema::NonNull === argument.type
GraphQL::Schema::NonNull.new(argument.loads)
GraphQL::Schema::NonNull.new(type)
else
GraphQL::Schema::Wrapper.new(argument.loads)
GraphQL::Schema::Wrapper.new(type)
end
else
argument.type
Expand Down
7 changes: 4 additions & 3 deletions spec/tapioca/dsl/compilers/graphql_mutation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ class CreateComment < GraphQL::Schema::Mutation
argument :custom_scalar, CustomScalar, required: true
argument :loaded_argument_id, ID, required: true, loads: LoadedType
argument :loaded_argument_optional_id, ID, required: false, loads: LoadedType
argument :loaded_argument_ids, [ID], required: true, loads: LoadedType
def resolve(boolean:, float:, id:, int:, date:, datetime:, json:, string:, enum_a:, enum_b:, input_object:, custom_scalar:, loaded_argument:, loaded_argument_optional: nil)
def resolve(boolean:, float:, id:, int:, date:, datetime:, json:, string:, enum_a:, enum_b:, input_object:, custom_scalar:, loaded_argument:, loaded_arguments:, loaded_argument_optional: nil)
# ...
end
end
Expand All @@ -144,8 +145,8 @@ def resolve(boolean:, float:, id:, int:, date:, datetime:, json:, string:, enum_
# typed: strong
class CreateComment
sig { params(boolean: T::Boolean, float: ::Float, id: ::String, int: ::Integer, date: ::Date, datetime: ::Time, json: T::Hash[::String, T.untyped], string: ::String, enum_a: ::String, enum_b: T.any(::String, ::Symbol), input_object: ::CreateCommentInput, custom_scalar: T.untyped, loaded_argument: T.untyped, loaded_argument_optional: T.untyped).returns(T.untyped) }
def resolve(boolean:, float:, id:, int:, date:, datetime:, json:, string:, enum_a:, enum_b:, input_object:, custom_scalar:, loaded_argument:, loaded_argument_optional: T.unsafe(nil)); end
sig { params(boolean: T::Boolean, float: ::Float, id: ::String, int: ::Integer, date: ::Date, datetime: ::Time, json: T::Hash[::String, T.untyped], string: ::String, enum_a: ::String, enum_b: T.any(::String, ::Symbol), input_object: ::CreateCommentInput, custom_scalar: T.untyped, loaded_argument: T.untyped, loaded_arguments: T::Array[T.untyped], loaded_argument_optional: T.untyped).returns(T.untyped) }
def resolve(boolean:, float:, id:, int:, date:, datetime:, json:, string:, enum_a:, enum_b:, input_object:, custom_scalar:, loaded_argument:, loaded_arguments:, loaded_argument_optional: T.unsafe(nil)); end
end
RBI

Expand Down

0 comments on commit e16efa7

Please sign in to comment.