bluejay 0.1.0.alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/Cargo.lock +423 -0
  3. data/Cargo.toml +2 -0
  4. data/LICENSE +21 -0
  5. data/README.md +33 -0
  6. data/ext/Cargo.toml +17 -0
  7. data/ext/extconf.rb +6 -0
  8. data/ext/src/execution/coerce_result.rs +54 -0
  9. data/ext/src/execution/engine.rs +466 -0
  10. data/ext/src/execution/execution_error.rs +28 -0
  11. data/ext/src/execution/field_error.rs +8 -0
  12. data/ext/src/execution/key_store.rs +23 -0
  13. data/ext/src/execution.rs +10 -0
  14. data/ext/src/helpers/public_name.rs +21 -0
  15. data/ext/src/helpers/typed_frozen_r_array.rs +56 -0
  16. data/ext/src/helpers/wrapped_definition.rs +79 -0
  17. data/ext/src/helpers/wrapped_struct.rs +97 -0
  18. data/ext/src/helpers.rs +8 -0
  19. data/ext/src/lib.rs +10 -0
  20. data/ext/src/ruby_api/arguments_definition.rs +8 -0
  21. data/ext/src/ruby_api/coerce_input.rs +6 -0
  22. data/ext/src/ruby_api/coercion_error.rs +61 -0
  23. data/ext/src/ruby_api/custom_scalar_type_definition.rs +62 -0
  24. data/ext/src/ruby_api/enum_type_definition.rs +107 -0
  25. data/ext/src/ruby_api/enum_value_definition.rs +58 -0
  26. data/ext/src/ruby_api/enum_value_definitions.rs +8 -0
  27. data/ext/src/ruby_api/execution_error.rs +48 -0
  28. data/ext/src/ruby_api/execution_result.rs +40 -0
  29. data/ext/src/ruby_api/field_definition.rs +112 -0
  30. data/ext/src/ruby_api/fields_definition.rs +8 -0
  31. data/ext/src/ruby_api/input_fields_definition.rs +8 -0
  32. data/ext/src/ruby_api/input_object_type_definition.rs +138 -0
  33. data/ext/src/ruby_api/input_type_reference.rs +358 -0
  34. data/ext/src/ruby_api/input_value_definition.rs +98 -0
  35. data/ext/src/ruby_api/interface_implementation.rs +42 -0
  36. data/ext/src/ruby_api/interface_implementations.rs +8 -0
  37. data/ext/src/ruby_api/interface_type_definition.rs +82 -0
  38. data/ext/src/ruby_api/json_value.rs +111 -0
  39. data/ext/src/ruby_api/object_type_definition.rs +100 -0
  40. data/ext/src/ruby_api/output_type_reference.rs +238 -0
  41. data/ext/src/ruby_api/r_result.rs +84 -0
  42. data/ext/src/ruby_api/scalar.rs +45 -0
  43. data/ext/src/ruby_api/schema_definition.rs +270 -0
  44. data/ext/src/ruby_api/union_member_type.rs +41 -0
  45. data/ext/src/ruby_api/union_member_types.rs +8 -0
  46. data/ext/src/ruby_api/union_type_definition.rs +89 -0
  47. data/ext/src/ruby_api/validation_error.rs +63 -0
  48. data/ext/src/ruby_api.rs +75 -0
  49. data/lib/bluejay/base_input_type_reference.rb +13 -0
  50. data/lib/bluejay/base_output_type_reference.rb +15 -0
  51. data/lib/bluejay/custom_scalar_type.rb +40 -0
  52. data/lib/bluejay/enum_type.rb +44 -0
  53. data/lib/bluejay/ext.bundle +0 -0
  54. data/lib/bluejay/finalize.rb +27 -0
  55. data/lib/bluejay/input_type.rb +64 -0
  56. data/lib/bluejay/input_type_reference_shorthands.rb +28 -0
  57. data/lib/bluejay/interface_type.rb +60 -0
  58. data/lib/bluejay/json_value.rb +16 -0
  59. data/lib/bluejay/name_from_class.rb +18 -0
  60. data/lib/bluejay/object_type.rb +68 -0
  61. data/lib/bluejay/output_type_reference_shorthands.rb +28 -0
  62. data/lib/bluejay/schema.rb +63 -0
  63. data/lib/bluejay/union_type.rb +43 -0
  64. data/lib/bluejay/version.rb +5 -0
  65. data/lib/bluejay.rb +28 -0
  66. data/lib/rbi_ext/model.rb +64 -0
  67. data/lib/tapioca/dsl/compilers/input_type.rb +34 -0
  68. data/lib/tapioca/dsl/compilers/interface_type.rb +29 -0
  69. data/lib/tapioca/dsl/compilers/object_type.rb +43 -0
  70. data/lib/tapioca/dsl/compilers/schema.rb +42 -0
  71. metadata +131 -0
@@ -0,0 +1,15 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Bluejay
5
+ BaseOutputTypeReference = T.type_alias do
6
+ T.any(
7
+ Scalar,
8
+ T.class_of(EnumType),
9
+ T.class_of(ObjectType),
10
+ T.class_of(UnionType),
11
+ T.class_of(InterfaceType),
12
+ T.class_of(CustomScalarType),
13
+ )
14
+ end
15
+ end
@@ -0,0 +1,40 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Bluejay
5
+ class CustomScalarType
6
+ extend(Finalize)
7
+
8
+ class << self
9
+ extend(T::Sig)
10
+ extend(T::Helpers)
11
+ include(NameFromClass)
12
+
13
+ abstract!
14
+
15
+ sig { overridable.returns(String) }
16
+ def graphql_name
17
+ name_from_class
18
+ end
19
+
20
+ sig { overridable.returns(T.nilable(String)) }
21
+ def description
22
+ nil
23
+ end
24
+
25
+ protected
26
+
27
+ sig(:final) { override.void }
28
+ def finalize
29
+ definition
30
+ end
31
+
32
+ private
33
+
34
+ sig(:final) { returns(CustomScalarTypeDefinition) }
35
+ def definition
36
+ @definition ||= T.let(CustomScalarTypeDefinition.new(name: graphql_name, description:), T.nilable(CustomScalarTypeDefinition))
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,44 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Bluejay
5
+ class EnumType
6
+ extend(Finalize)
7
+
8
+ class << self
9
+ extend(T::Sig)
10
+ extend(T::Helpers)
11
+ include(NameFromClass)
12
+
13
+ abstract!
14
+
15
+ sig { overridable.returns(String) }
16
+ def graphql_name
17
+ name_from_class
18
+ end
19
+
20
+ sig { overridable.returns(T.nilable(String)) }
21
+ def description
22
+ nil
23
+ end
24
+
25
+ sig { abstract.returns(T::Array[EnumValueDefinition]) }
26
+ def enum_value_definitions; end
27
+
28
+ protected
29
+
30
+ sig(:final) { override.void }
31
+ def finalize
32
+ definition
33
+ end
34
+
35
+ private
36
+
37
+ sig(:final) { returns(EnumTypeDefinition) }
38
+ def definition
39
+ @definition ||= T.let(nil, T.nilable(EnumTypeDefinition))
40
+ @definition ||= EnumTypeDefinition.new(name: graphql_name, enum_value_definitions:, description:)
41
+ end
42
+ end
43
+ end
44
+ end
Binary file
@@ -0,0 +1,27 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Bluejay
5
+ module Finalize
6
+ extend(T::Sig)
7
+ extend(T::Helpers)
8
+
9
+ abstract!
10
+
11
+ sig { abstract.void }
12
+ def finalize; end
13
+
14
+ sig { params(obj: Finalize).void }
15
+ def inherited(obj)
16
+ TracePoint.trace(:end) do |t|
17
+ if obj == t.self
18
+ obj.finalize
19
+ t.disable
20
+ end
21
+ end
22
+ super
23
+ end
24
+ end
25
+
26
+ private_constant(:Finalize)
27
+ end
@@ -0,0 +1,64 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Bluejay
5
+ class InputType
6
+ extend(Finalize)
7
+
8
+ class << self
9
+ extend(T::Sig)
10
+ extend(T::Helpers)
11
+ include(InputTypeReferenceShorthands)
12
+ include(NameFromClass)
13
+
14
+ abstract!
15
+
16
+ sig { overridable.returns(String) }
17
+ def graphql_name
18
+ name_from_class
19
+ end
20
+
21
+ sig { overridable.returns(T.nilable(String)) }
22
+ def description
23
+ nil
24
+ end
25
+
26
+ sig { abstract.returns(T::Array[InputValueDefinition]) }
27
+ def input_field_definitions; end
28
+
29
+ sig { params(value: T.untyped).returns(Result[T.untyped, T::Array[CoercionError]]) }
30
+ def coerce_input(value)
31
+ definition.coerce_input(value)
32
+ end
33
+
34
+ protected
35
+
36
+ sig(:final) { override.void }
37
+ def finalize
38
+ definition
39
+ end
40
+
41
+ private
42
+
43
+ sig(:final) { returns(InputObjectTypeDefinition) }
44
+ def definition
45
+ @definition ||= T.let(nil, T.nilable(InputObjectTypeDefinition))
46
+ @definition ||= begin
47
+ self.define_method(:initialize) do |*args|
48
+ self.class.send(:definition).input_field_definitions.zip(args) do |ivd, arg|
49
+ self.instance_variable_set("@#{ivd.name}", arg)
50
+ end
51
+ end
52
+ self.define_method(:==) do |other|
53
+ self.class == other.class && self.class.send(:definition).input_field_definitions.all? do |ivd|
54
+ self.send(ivd.name) == other.send(ivd.name)
55
+ end
56
+ end
57
+ input_field_definitions = self.input_field_definitions
58
+ input_field_definitions.each { |ivd| self.attr_reader(ivd.name) }
59
+ InputObjectTypeDefinition.new(name: graphql_name, input_field_definitions:, description:, ruby_class: self)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,28 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Bluejay
5
+ module InputTypeReferenceShorthands
6
+ extend(T::Sig)
7
+
8
+ sig { params(t: BaseInputTypeReference).returns(InputTypeReference) }
9
+ def it(t)
10
+ InputTypeReference.new(type: t, required: false)
11
+ end
12
+
13
+ sig { params(t: BaseInputTypeReference).returns(InputTypeReference) }
14
+ def it!(t)
15
+ InputTypeReference.new(type: t, required: true)
16
+ end
17
+
18
+ sig { params(t: InputTypeReference).returns(InputTypeReference) }
19
+ def lit(t)
20
+ InputTypeReference.list(type: t, required: false)
21
+ end
22
+
23
+ sig { params(t: InputTypeReference).returns(InputTypeReference) }
24
+ def lit!(t)
25
+ InputTypeReference.list(type: t, required: true)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,60 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Bluejay
5
+ class InterfaceType
6
+ extend(Finalize)
7
+
8
+ class << self
9
+ extend(T::Sig)
10
+ extend(T::Helpers)
11
+ include(OutputTypeReferenceShorthands)
12
+ include(InputTypeReferenceShorthands)
13
+ include(NameFromClass)
14
+
15
+ abstract!
16
+
17
+ sig { overridable.returns(String) }
18
+ def graphql_name
19
+ name_from_class
20
+ end
21
+
22
+ sig { overridable.returns(T.nilable(String)) }
23
+ def description
24
+ nil
25
+ end
26
+
27
+ sig { abstract.returns(T::Array[FieldDefinition]) }
28
+ def field_definitions; end
29
+
30
+ sig { overridable.returns(T::Array[InterfaceImplementation]) }
31
+ def interface_implementations
32
+ []
33
+ end
34
+
35
+ protected
36
+
37
+ sig(:final) { override.void }
38
+ def finalize
39
+ definition
40
+ end
41
+
42
+ private
43
+
44
+ sig { returns(InterfaceTypeDefinition) }
45
+ def definition
46
+ @definition ||= T.let(nil, T.nilable(InterfaceTypeDefinition))
47
+ @definition ||= begin
48
+ interface_implementations = self.interface_implementations
49
+ interface = Module.new do |mod|
50
+ interface_implementations.each do |interface_implementation|
51
+ mod.include(interface_implementation.interface.const_get(:Interface))
52
+ end
53
+ end
54
+ const_set(:Interface, interface)
55
+ InterfaceTypeDefinition.new(name: graphql_name, description:, field_definitions:, interface_implementations:)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,16 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Bluejay
5
+ JsonValue = T.type_alias do
6
+ T.any(
7
+ NilClass,
8
+ Integer,
9
+ Float,
10
+ String,
11
+ T::Boolean,
12
+ T::Array[Object],
13
+ T::Hash[String, Object],
14
+ )
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Bluejay
5
+ module NameFromClass
6
+ extend(T::Sig)
7
+ extend(T::Helpers)
8
+
9
+ requires_ancestor { Class }
10
+
11
+ private
12
+
13
+ sig { returns(String) }
14
+ def name_from_class
15
+ name&.split("::")&.last || "Anonymous"
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,68 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Bluejay
5
+ class ObjectType
6
+ extend(Finalize)
7
+
8
+ class << self
9
+ extend(T::Sig)
10
+ extend(T::Helpers)
11
+ include(OutputTypeReferenceShorthands)
12
+ include(InputTypeReferenceShorthands)
13
+ include(NameFromClass)
14
+
15
+ abstract!
16
+
17
+ sig { overridable.returns(String) }
18
+ def graphql_name
19
+ name_from_class
20
+ end
21
+
22
+ sig { overridable.returns(T.nilable(String)) }
23
+ def description
24
+ nil
25
+ end
26
+
27
+ sig { abstract.returns(T::Array[FieldDefinition]) }
28
+ def field_definitions; end
29
+
30
+ sig { overridable.returns(T::Array[InterfaceImplementation]) }
31
+ def interface_implementations
32
+ []
33
+ end
34
+
35
+ protected
36
+
37
+ sig(:final) { override.void }
38
+ def finalize
39
+ definition
40
+ end
41
+
42
+ private
43
+
44
+ sig { returns(ObjectTypeDefinition) }
45
+ def definition
46
+ @definition ||= T.let(nil, T.nilable(ObjectTypeDefinition))
47
+ @definition ||= begin
48
+ graphql_name = self.graphql_name
49
+ field_definitions = self.field_definitions
50
+ interface_implementations = self.interface_implementations
51
+ interface = Module.new do |mod|
52
+ field_definitions.each do |field_definition|
53
+ mod.define_method(field_definition.resolver_method_name) { graphql_name }
54
+ end
55
+
56
+ interface_implementations.each do |interface_implementation|
57
+ mod.include(interface_implementation.interface.const_get(:Interface))
58
+ end
59
+
60
+ mod.define_method(:resolve_typename) { graphql_name }
61
+ end
62
+ const_set(:Interface, interface)
63
+ ObjectTypeDefinition.new(name: graphql_name, description:, field_definitions:, interface_implementations:)
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,28 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Bluejay
5
+ module OutputTypeReferenceShorthands
6
+ extend(T::Sig)
7
+
8
+ sig { params(t: BaseOutputTypeReference).returns(OutputTypeReference) }
9
+ def ot(t)
10
+ OutputTypeReference.new(type: t, required: false)
11
+ end
12
+
13
+ sig { params(t: BaseOutputTypeReference).returns(OutputTypeReference) }
14
+ def ot!(t)
15
+ OutputTypeReference.new(type: t, required: true)
16
+ end
17
+
18
+ sig { params(t: OutputTypeReference).returns(OutputTypeReference) }
19
+ def lot(t)
20
+ OutputTypeReference.list(type: t, required: false)
21
+ end
22
+
23
+ sig { params(t: OutputTypeReference).returns(OutputTypeReference) }
24
+ def lot!(t)
25
+ OutputTypeReference.list(type: t, required: true)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,63 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Bluejay
5
+ class Schema
6
+ extend(Finalize)
7
+
8
+ class << self
9
+ extend(T::Sig)
10
+ extend(T::Helpers)
11
+
12
+ abstract!
13
+
14
+ sig { overridable.returns(T.nilable(String)) }
15
+ def description
16
+ nil
17
+ end
18
+
19
+ sig { abstract.returns(T.class_of(ObjectType)) }
20
+ def query; end
21
+
22
+ sig { overridable.returns(T.nilable(T.class_of(ObjectType))) }
23
+ def mutation
24
+ nil
25
+ end
26
+
27
+ sig { params(query: String, operation_name: T.nilable(String), initial_value: Object, variables: T::Hash[String, T.untyped]).returns(ExecutionResult) }
28
+ def execute(query:, operation_name:, initial_value:, variables: {})
29
+ definition.execute(query, operation_name, variables, initial_value)
30
+ end
31
+
32
+ sig { params(query: String).returns(T::Array[ValidationError]) }
33
+ def validate_query(query:)
34
+ definition.validate_query(query)
35
+ end
36
+
37
+ protected
38
+
39
+ sig(:final) { override.void }
40
+ def finalize
41
+ definition
42
+ end
43
+
44
+ private
45
+
46
+ sig { returns(SchemaDefinition) }
47
+ def definition
48
+ @definition ||= T.let(nil, T.nilable(SchemaDefinition))
49
+ @definition ||= begin
50
+ mutation = self.mutation
51
+ interface = Module.new do |mod|
52
+ mod.define_method(:query) {}
53
+ if mutation
54
+ mod.define_method(:mutation) {}
55
+ end
56
+ end
57
+ const_set(:Root, interface)
58
+ SchemaDefinition.new(description:, query:, mutation:)
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,43 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Bluejay
5
+ class UnionType
6
+ extend(Finalize)
7
+
8
+ class << self
9
+ extend(T::Sig)
10
+ extend(T::Helpers)
11
+ include(NameFromClass)
12
+
13
+ abstract!
14
+
15
+ sig { overridable.returns(String) }
16
+ def graphql_name
17
+ name_from_class
18
+ end
19
+
20
+ sig { overridable.returns(T.nilable(String)) }
21
+ def description
22
+ nil
23
+ end
24
+
25
+ sig { abstract.returns(T::Array[UnionMemberType]) }
26
+ def member_types; end
27
+
28
+ protected
29
+
30
+ sig(:final) { override.void }
31
+ def finalize
32
+ definition
33
+ end
34
+
35
+ private
36
+
37
+ sig { returns(UnionTypeDefinition) }
38
+ def definition
39
+ @definition ||= T.let(UnionTypeDefinition.new(name: graphql_name, description:, member_types:), T.nilable(UnionTypeDefinition))
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bluejay
4
+ VERSION = "0.1.0.alpha.1"
5
+ end
data/lib/bluejay.rb ADDED
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "bluejay/version"
4
+ require "sorbet-runtime"
5
+ require_relative "bluejay/finalize"
6
+ require_relative "bluejay/name_from_class"
7
+ require_relative "bluejay/base_input_type_reference"
8
+ require_relative "bluejay/base_output_type_reference"
9
+ require_relative "bluejay/input_type_reference_shorthands"
10
+ require_relative "bluejay/output_type_reference_shorthands"
11
+ require_relative "bluejay/json_value"
12
+ require_relative "bluejay/custom_scalar_type"
13
+ require_relative "bluejay/enum_type"
14
+ require_relative "bluejay/interface_type"
15
+ require_relative "bluejay/input_type"
16
+ require_relative "bluejay/object_type"
17
+ require_relative "bluejay/schema"
18
+ require_relative "bluejay/union_type"
19
+
20
+ begin
21
+ RUBY_VERSION =~ /(\d+\.\d+)/
22
+ require "bluejay/#{Regexp.last_match(1)}/ext"
23
+ rescue LoadError
24
+ require "bluejay/ext"
25
+ end
26
+
27
+ module Bluejay
28
+ end
@@ -0,0 +1,64 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module RBI
5
+ class Tree
6
+ extend T::Sig
7
+
8
+ # originally from:
9
+ # https://github.com/Shopify/tapioca/blob/7ea79ff61ac418ee2f5f573eec8a1f005db13ebd/lib/tapioca/rbi_ext/model.rb#L79-L106
10
+ sig do
11
+ params(
12
+ name: String,
13
+ return_type: T.nilable(String),
14
+ parameters: T::Array[TypedParam],
15
+ class_method: T::Boolean,
16
+ visibility: RBI::Visibility,
17
+ comments: T::Array[RBI::Comment],
18
+ is_final: T::Boolean,
19
+ is_abstract: T::Boolean,
20
+ ).void
21
+ end
22
+ def custom_create_method(name, return_type:, parameters: [], class_method: false, visibility: RBI::Public.new,
23
+ comments: [], is_final: false, is_abstract: false)
24
+ return unless Tapioca::RBIHelper.valid_method_name?(name)
25
+
26
+ sig = RBI::Sig.new(return_type:, is_final:, is_abstract:)
27
+ method = RBI::Method.new(
28
+ name,
29
+ sigs: [sig],
30
+ is_singleton: class_method,
31
+ visibility:,
32
+ comments:,
33
+ )
34
+ parameters.each do |param|
35
+ method << param.param
36
+ sig << RBI::SigParam.new(param.param.name, param.type)
37
+ end
38
+ self << method
39
+ end
40
+
41
+ sig { void }
42
+ def mark_abstract
43
+ add_helper("abstract")
44
+ end
45
+
46
+ sig { void }
47
+ def mark_interface
48
+ add_helper("interface")
49
+ end
50
+
51
+ sig { params(name: String).void }
52
+ def create_include(name)
53
+ self << RBI::Include.new(name)
54
+ end
55
+
56
+ private
57
+
58
+ sig { params(name: String).void }
59
+ def add_helper(name)
60
+ helper = RBI::Helper.new(name)
61
+ self << helper
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,34 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../../../rbi_ext/model"
5
+
6
+ module Tapioca
7
+ module Compilers
8
+ class InputType < Tapioca::Dsl::Compiler
9
+ extend T::Sig
10
+
11
+ ConstantType = type_member { { fixed: T.class_of(Bluejay::InputType) } }
12
+
13
+ sig { override.returns(T::Enumerable[Module]) }
14
+ def self.gather_constants
15
+ all_classes.select { |c| c < Bluejay::InputType }
16
+ end
17
+
18
+ sig { override.void }
19
+ def decorate
20
+ root.create_path(constant) do |klass|
21
+ parameters = constant.input_field_definitions.map do |input_field_definition|
22
+ create_param(input_field_definition.ruby_name, type: input_field_definition.type.sorbet_type)
23
+ end
24
+
25
+ klass.custom_create_method("initialize", parameters:, return_type: nil)
26
+
27
+ constant.input_field_definitions.each do |input_field_definition|
28
+ klass.custom_create_method(input_field_definition.ruby_name, return_type: input_field_definition.type.sorbet_type)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,29 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../../../rbi_ext/model"
5
+
6
+ module Tapioca
7
+ module Compilers
8
+ class InterfaceType < Tapioca::Dsl::Compiler
9
+ extend T::Sig
10
+
11
+ ConstantType = type_member { { fixed: T.class_of(Bluejay::InterfaceType) } }
12
+
13
+ sig { override.returns(T::Enumerable[Module]) }
14
+ def self.gather_constants
15
+ all_classes.select { |c| c < Bluejay::InterfaceType }
16
+ end
17
+
18
+ sig { override.void }
19
+ def decorate
20
+ root.create_path(constant.const_get(:Interface)) do |klass|
21
+ constant.interface_implementations.each do |interface_implementation|
22
+ interface = interface_implementation.interface.const_get(:Interface)
23
+ klass.create_include(interface.name)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end