tapioca 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +2 -2
- data/lib/tapioca/dsl/compilers/graphql_input_object.rb +1 -3
- data/lib/tapioca/dsl/compilers/graphql_mutation.rb +1 -2
- data/lib/tapioca/dsl/helpers/graphql_type_helper.rb +21 -17
- data/lib/tapioca/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 555978fd8996f91539408f4e1c251bf30933d800deab606a63974088f59d8525
|
4
|
+
data.tar.gz: 249a48a0c8a9cc73d56334b2a83b26b356a920747b7ba4b83e1c92575ba1d158
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 819cb6fc4c0fb0adbbf79ad4250147c6753b87f257a9c9d869419ca4db68ad869aea78fbbb995a71e1cee31b06a237df34f680bc1c97e3f3b7ea62c4c67b6b16
|
7
|
+
data.tar.gz: e28b2f755e4ff5aab74cacc4f7141e5c93ee2b0ca8e1818c068b0c4ef5ba6e76e06cfbc5775f8e03babc50309df8d85c20c30708e9656bb714f506cb7ed8434d
|
@@ -31,7 +31,7 @@ module Tapioca
|
|
31
31
|
# # test_case.rbi
|
32
32
|
# # typed: true
|
33
33
|
# class ActiveSupport::TestCase
|
34
|
-
# sig { params(fixture_names: Symbol).returns(T.untyped) }
|
34
|
+
# sig { params(fixture_names: T.any(String, Symbol)).returns(T.untyped) }
|
35
35
|
# def posts(*fixture_names); end
|
36
36
|
# end
|
37
37
|
# ~~~
|
@@ -99,7 +99,7 @@ module Tapioca
|
|
99
99
|
def create_fixture_method(mod, name)
|
100
100
|
mod.create_method(
|
101
101
|
name,
|
102
|
-
parameters: [create_rest_param("fixture_names", type: "Symbol")],
|
102
|
+
parameters: [create_rest_param("fixture_names", type: "T.any(String, Symbol)")],
|
103
103
|
return_type: "T.untyped"
|
104
104
|
)
|
105
105
|
end
|
@@ -47,12 +47,10 @@ module Tapioca
|
|
47
47
|
arguments = constant.all_argument_definitions
|
48
48
|
return if arguments.empty?
|
49
49
|
|
50
|
-
graphql_type_helper = Helpers::GraphqlTypeHelper.new
|
51
|
-
|
52
50
|
root.create_path(constant) do |input_object|
|
53
51
|
arguments.each do |argument|
|
54
52
|
name = argument.keyword.to_s
|
55
|
-
input_object.create_method(name, return_type:
|
53
|
+
input_object.create_method(name, return_type: Helpers::GraphqlTypeHelper.type_for(argument.type))
|
56
54
|
end
|
57
55
|
end
|
58
56
|
end
|
@@ -54,12 +54,11 @@ module Tapioca
|
|
54
54
|
return if arguments.empty?
|
55
55
|
|
56
56
|
arguments_by_name = arguments.to_h { |a| [a.keyword.to_s, a] }
|
57
|
-
graphql_type_helper = Helpers::GraphqlTypeHelper.new
|
58
57
|
|
59
58
|
params = compile_method_parameters_to_rbi(method_def).map do |param|
|
60
59
|
name = param.param.name
|
61
60
|
argument = arguments_by_name.fetch(name, nil)
|
62
|
-
create_typed_param(param.param, argument ?
|
61
|
+
create_typed_param(param.param, argument ? Helpers::GraphqlTypeHelper.type_for(argument.type) : "T.untyped")
|
63
62
|
end
|
64
63
|
|
65
64
|
root.create_path(constant) do |mutation|
|
@@ -4,10 +4,10 @@
|
|
4
4
|
module Tapioca
|
5
5
|
module Dsl
|
6
6
|
module Helpers
|
7
|
-
|
7
|
+
module GraphqlTypeHelper
|
8
|
+
extend self
|
9
|
+
|
8
10
|
extend T::Sig
|
9
|
-
include RBIHelper
|
10
|
-
include Runtime::Reflection
|
11
11
|
|
12
12
|
sig { params(type: GraphQL::Schema::Wrapper).returns(String) }
|
13
13
|
def type_for(type)
|
@@ -17,45 +17,49 @@ module Tapioca
|
|
17
17
|
when GraphQL::Types::Boolean.singleton_class
|
18
18
|
"T::Boolean"
|
19
19
|
when GraphQL::Types::Float.singleton_class
|
20
|
-
|
21
|
-
when GraphQL::Types::ID.singleton_class
|
22
|
-
|
20
|
+
type_for_constant(Float)
|
21
|
+
when GraphQL::Types::ID.singleton_class, GraphQL::Types::String.singleton_class
|
22
|
+
type_for_constant(String)
|
23
23
|
when GraphQL::Types::Int.singleton_class
|
24
|
-
|
24
|
+
type_for_constant(Integer)
|
25
25
|
when GraphQL::Types::ISO8601Date.singleton_class
|
26
|
-
|
26
|
+
type_for_constant(Date)
|
27
27
|
when GraphQL::Types::ISO8601DateTime.singleton_class
|
28
|
-
|
28
|
+
type_for_constant(DateTime)
|
29
29
|
when GraphQL::Types::JSON.singleton_class
|
30
30
|
"T::Hash[::String, T.untyped]"
|
31
|
-
when GraphQL::Types::String.singleton_class
|
32
|
-
qualified_name_of(String)
|
33
31
|
when GraphQL::Schema::Enum.singleton_class
|
34
32
|
enum_values = T.cast(unwrapped_type.enum_values, T::Array[GraphQL::Schema::EnumValue])
|
35
|
-
value_types = enum_values.map { |v|
|
33
|
+
value_types = enum_values.map { |v| type_for_constant(v.value.class) }.uniq
|
34
|
+
|
36
35
|
if value_types.size == 1
|
37
|
-
value_types.first
|
36
|
+
T.must(value_types.first)
|
38
37
|
else
|
39
38
|
"T.any(#{value_types.join(", ")})"
|
40
39
|
end
|
41
40
|
when GraphQL::Schema::InputObject.singleton_class
|
42
|
-
|
41
|
+
type_for_constant(unwrapped_type)
|
43
42
|
else
|
44
43
|
"T.untyped"
|
45
44
|
end
|
46
45
|
|
47
|
-
parsed_type = T.must(parsed_type)
|
48
|
-
|
49
46
|
if type.list?
|
50
47
|
parsed_type = "T::Array[#{parsed_type}]"
|
51
48
|
end
|
52
49
|
|
53
50
|
unless type.non_null?
|
54
|
-
parsed_type = as_nilable_type(parsed_type)
|
51
|
+
parsed_type = RBIHelper.as_nilable_type(parsed_type)
|
55
52
|
end
|
56
53
|
|
57
54
|
parsed_type
|
58
55
|
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
sig { params(constant: Module).returns(String) }
|
60
|
+
def type_for_constant(constant)
|
61
|
+
Runtime::Reflection.qualified_name_of(constant) || "T.untyped"
|
62
|
+
end
|
59
63
|
end
|
60
64
|
end
|
61
65
|
end
|
data/lib/tapioca/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tapioca
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ufuk Kayserilioglu
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2022-
|
14
|
+
date: 2022-09-14 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|