bluejay 0.1.0.alpha.2-x86_64-darwin
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.
- checksums.yaml +7 -0
 - data/LICENSE +21 -0
 - data/README.md +411 -0
 - data/lib/bluejay/3.1/bluejay_rb.bundle +0 -0
 - data/lib/bluejay/3.2/bluejay_rb.bundle +0 -0
 - data/lib/bluejay/base/custom_scalar_type.rb +25 -0
 - data/lib/bluejay/base/directive.rb +25 -0
 - data/lib/bluejay/base/enum_type.rb +25 -0
 - data/lib/bluejay/base/input_object_type.rb +25 -0
 - data/lib/bluejay/base/interface_type.rb +25 -0
 - data/lib/bluejay/base/object_type.rb +25 -0
 - data/lib/bluejay/base/query_root.rb +25 -0
 - data/lib/bluejay/base/schema.rb +25 -0
 - data/lib/bluejay/base/union_type.rb +25 -0
 - data/lib/bluejay/base.rb +11 -0
 - data/lib/bluejay/base_input_type.rb +13 -0
 - data/lib/bluejay/base_output_type.rb +15 -0
 - data/lib/bluejay/builtin/directives/deprecated.rb +34 -0
 - data/lib/bluejay/builtin/directives/include.rb +35 -0
 - data/lib/bluejay/builtin/directives/skip.rb +35 -0
 - data/lib/bluejay/builtin/directives/specified_by.rb +33 -0
 - data/lib/bluejay/builtin/enum_types/directive_location.rb +44 -0
 - data/lib/bluejay/builtin/enum_types/type_kind.rb +33 -0
 - data/lib/bluejay/builtin/object_types/directive.rb +34 -0
 - data/lib/bluejay/builtin/object_types/enum_value.rb +33 -0
 - data/lib/bluejay/builtin/object_types/field.rb +35 -0
 - data/lib/bluejay/builtin/object_types/input_value.rb +29 -0
 - data/lib/bluejay/builtin/object_types/schema.rb +31 -0
 - data/lib/bluejay/builtin/object_types/type.rb +57 -0
 - data/lib/bluejay/builtin.rb +25 -0
 - data/lib/bluejay/custom_scalar_type.rb +69 -0
 - data/lib/bluejay/directive.rb +71 -0
 - data/lib/bluejay/enum_type.rb +48 -0
 - data/lib/bluejay/errors.rb +20 -0
 - data/lib/bluejay/finalize.rb +27 -0
 - data/lib/bluejay/input_object_type.rb +73 -0
 - data/lib/bluejay/input_type_shorthands.rb +28 -0
 - data/lib/bluejay/interface_type.rb +74 -0
 - data/lib/bluejay/json_value.rb +16 -0
 - data/lib/bluejay/name_from_class.rb +18 -0
 - data/lib/bluejay/object_type.rb +81 -0
 - data/lib/bluejay/output_type_shorthands.rb +28 -0
 - data/lib/bluejay/query_root.rb +64 -0
 - data/lib/bluejay/schema.rb +91 -0
 - data/lib/bluejay/union_type.rb +50 -0
 - data/lib/bluejay/version.rb +5 -0
 - data/lib/bluejay.rb +45 -0
 - data/lib/rbi_ext/model.rb +64 -0
 - data/lib/tapioca/dsl/compilers/directive.rb +42 -0
 - data/lib/tapioca/dsl/compilers/input_object_type.rb +41 -0
 - data/lib/tapioca/dsl/compilers/interface_type.rb +33 -0
 - data/lib/tapioca/dsl/compilers/object_type.rb +53 -0
 - data/lib/tapioca/dsl/compilers/schema.rb +51 -0
 - data/rust-toolchain.toml +2 -0
 - metadata +118 -0
 
| 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # typed: strict
         
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module Bluejay
         
     | 
| 
      
 5 
     | 
    
         
            +
              module Errors
         
     | 
| 
      
 6 
     | 
    
         
            +
                class BaseError < StandardError; end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                class DefaultValueError < BaseError
         
     | 
| 
      
 9 
     | 
    
         
            +
                  extend(T::Sig)
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  sig { params(errors: T::Array[CoercionError], value: Object).void }
         
     | 
| 
      
 12 
     | 
    
         
            +
                  def initialize(errors, value)
         
     | 
| 
      
 13 
     | 
    
         
            +
                    @errors = errors
         
     | 
| 
      
 14 
     | 
    
         
            +
                    super("Invalid default value: #{value}. Errors:\n#{errors.map(&:message).join("\n")}")
         
     | 
| 
      
 15 
     | 
    
         
            +
                  end
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                class NonUniqueDefinitionNameError < BaseError; end
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -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,73 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # typed: strict
         
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module Bluejay
         
     | 
| 
      
 5 
     | 
    
         
            +
              class InputObjectType
         
     | 
| 
      
 6 
     | 
    
         
            +
                extend(T::Sig)
         
     | 
| 
      
 7 
     | 
    
         
            +
                include(Base::InputObjectType)
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 10 
     | 
    
         
            +
                  extend(T::Sig)
         
     | 
| 
      
 11 
     | 
    
         
            +
                  extend(T::Helpers)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  include(InputTypeShorthands)
         
     | 
| 
      
 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[InputValueDefinition]) }
         
     | 
| 
      
 28 
     | 
    
         
            +
                  def input_field_definitions; end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  sig { overridable.returns(T::Array[Directive]) }
         
     | 
| 
      
 31 
     | 
    
         
            +
                  def directives
         
     | 
| 
      
 32 
     | 
    
         
            +
                    []
         
     | 
| 
      
 33 
     | 
    
         
            +
                  end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                  sig { params(value: T.untyped).returns(Result[T.untyped, T::Array[CoercionError]]) }
         
     | 
| 
      
 36 
     | 
    
         
            +
                  def coerce_input(value)
         
     | 
| 
      
 37 
     | 
    
         
            +
                    definition.coerce_input(value)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                  private
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                  sig(:final) { override.returns(InputObjectTypeDefinition) }
         
     | 
| 
      
 43 
     | 
    
         
            +
                  def definition
         
     | 
| 
      
 44 
     | 
    
         
            +
                    @definition ||= T.let(nil, T.nilable(InputObjectTypeDefinition))
         
     | 
| 
      
 45 
     | 
    
         
            +
                    @definition ||= begin
         
     | 
| 
      
 46 
     | 
    
         
            +
                      input_field_definitions = self.input_field_definitions
         
     | 
| 
      
 47 
     | 
    
         
            +
                      input_field_definitions.each { |ivd| attr_reader(ivd.ruby_name) }
         
     | 
| 
      
 48 
     | 
    
         
            +
                      InputObjectTypeDefinition.new(
         
     | 
| 
      
 49 
     | 
    
         
            +
                        name: graphql_name,
         
     | 
| 
      
 50 
     | 
    
         
            +
                        input_field_definitions:,
         
     | 
| 
      
 51 
     | 
    
         
            +
                        description:,
         
     | 
| 
      
 52 
     | 
    
         
            +
                        directives:,
         
     | 
| 
      
 53 
     | 
    
         
            +
                        ruby_class: self,
         
     | 
| 
      
 54 
     | 
    
         
            +
                      )
         
     | 
| 
      
 55 
     | 
    
         
            +
                    end
         
     | 
| 
      
 56 
     | 
    
         
            +
                  end
         
     | 
| 
      
 57 
     | 
    
         
            +
                end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                define_method(:initialize) do |**kwargs|
         
     | 
| 
      
 60 
     | 
    
         
            +
                  self.class.send(:definition).input_field_definitions.each do |ivd|
         
     | 
| 
      
 61 
     | 
    
         
            +
                    arg = kwargs[ivd.ruby_name]
         
     | 
| 
      
 62 
     | 
    
         
            +
                    instance_variable_set("@#{ivd.ruby_name}", arg)
         
     | 
| 
      
 63 
     | 
    
         
            +
                  end
         
     | 
| 
      
 64 
     | 
    
         
            +
                  freeze
         
     | 
| 
      
 65 
     | 
    
         
            +
                end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                define_method(:==) do |other|
         
     | 
| 
      
 68 
     | 
    
         
            +
                  self.class == other.class && self.class.send(:definition).input_field_definitions.all? do |ivd|
         
     | 
| 
      
 69 
     | 
    
         
            +
                    send(ivd.ruby_name) == other.send(ivd.ruby_name)
         
     | 
| 
      
 70 
     | 
    
         
            +
                  end
         
     | 
| 
      
 71 
     | 
    
         
            +
                end
         
     | 
| 
      
 72 
     | 
    
         
            +
              end
         
     | 
| 
      
 73 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # typed: strict
         
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module Bluejay
         
     | 
| 
      
 5 
     | 
    
         
            +
              module InputTypeShorthands
         
     | 
| 
      
 6 
     | 
    
         
            +
                extend(T::Sig)
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                sig { params(t: BaseInputType).returns(InputType) }
         
     | 
| 
      
 9 
     | 
    
         
            +
                def it(t)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  InputType.new(type: t, required: false)
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                sig { params(t: BaseInputType).returns(InputType) }
         
     | 
| 
      
 14 
     | 
    
         
            +
                def it!(t)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  InputType.new(type: t, required: true)
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                sig { params(t: InputType).returns(InputType) }
         
     | 
| 
      
 19 
     | 
    
         
            +
                def lit(t)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  InputType.list(type: t, required: false)
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                sig { params(t: InputType).returns(InputType) }
         
     | 
| 
      
 24 
     | 
    
         
            +
                def lit!(t)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  InputType.list(type: t, required: true)
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,74 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # typed: strict
         
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module Bluejay
         
     | 
| 
      
 5 
     | 
    
         
            +
              class InterfaceType
         
     | 
| 
      
 6 
     | 
    
         
            +
                include(Base::InterfaceType)
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 9 
     | 
    
         
            +
                  extend(T::Sig)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  extend(T::Helpers)
         
     | 
| 
      
 11 
     | 
    
         
            +
                  include(OutputTypeShorthands)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  include(InputTypeShorthands)
         
     | 
| 
      
 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 
     | 
    
         
            +
                  sig { overridable.returns(T::Array[Directive]) }
         
     | 
| 
      
 36 
     | 
    
         
            +
                  def directives
         
     | 
| 
      
 37 
     | 
    
         
            +
                    []
         
     | 
| 
      
 38 
     | 
    
         
            +
                  end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                  private
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                  sig { params(name: Symbol).returns(T.untyped) }
         
     | 
| 
      
 43 
     | 
    
         
            +
                  def const_missing(name)
         
     | 
| 
      
 44 
     | 
    
         
            +
                    if name == :Interface
         
     | 
| 
      
 45 
     | 
    
         
            +
                      definition
         
     | 
| 
      
 46 
     | 
    
         
            +
                      const_get(:Interface)
         
     | 
| 
      
 47 
     | 
    
         
            +
                    else
         
     | 
| 
      
 48 
     | 
    
         
            +
                      super
         
     | 
| 
      
 49 
     | 
    
         
            +
                    end
         
     | 
| 
      
 50 
     | 
    
         
            +
                  end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                  sig { override.returns(InterfaceTypeDefinition) }
         
     | 
| 
      
 53 
     | 
    
         
            +
                  def definition
         
     | 
| 
      
 54 
     | 
    
         
            +
                    @definition ||= T.let(nil, T.nilable(InterfaceTypeDefinition))
         
     | 
| 
      
 55 
     | 
    
         
            +
                    @definition ||= begin
         
     | 
| 
      
 56 
     | 
    
         
            +
                      interface_implementations = self.interface_implementations
         
     | 
| 
      
 57 
     | 
    
         
            +
                      interface = Module.new do |mod|
         
     | 
| 
      
 58 
     | 
    
         
            +
                        interface_implementations.each do |interface_implementation|
         
     | 
| 
      
 59 
     | 
    
         
            +
                          mod.include(T.cast(interface_implementation.interface, T.class_of(InterfaceType)).const_get(:Interface))
         
     | 
| 
      
 60 
     | 
    
         
            +
                        end
         
     | 
| 
      
 61 
     | 
    
         
            +
                      end
         
     | 
| 
      
 62 
     | 
    
         
            +
                      const_set(:Interface, interface)
         
     | 
| 
      
 63 
     | 
    
         
            +
                      InterfaceTypeDefinition.new(
         
     | 
| 
      
 64 
     | 
    
         
            +
                        name: graphql_name,
         
     | 
| 
      
 65 
     | 
    
         
            +
                        description:,
         
     | 
| 
      
 66 
     | 
    
         
            +
                        field_definitions: field_definitions + [Builtin.typename_field_definition],
         
     | 
| 
      
 67 
     | 
    
         
            +
                        interface_implementations:,
         
     | 
| 
      
 68 
     | 
    
         
            +
                        directives:,
         
     | 
| 
      
 69 
     | 
    
         
            +
                      )
         
     | 
| 
      
 70 
     | 
    
         
            +
                    end
         
     | 
| 
      
 71 
     | 
    
         
            +
                  end
         
     | 
| 
      
 72 
     | 
    
         
            +
                end
         
     | 
| 
      
 73 
     | 
    
         
            +
              end
         
     | 
| 
      
 74 
     | 
    
         
            +
            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 { Module }
         
     | 
| 
      
 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,81 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # typed: strict
         
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module Bluejay
         
     | 
| 
      
 5 
     | 
    
         
            +
              class ObjectType
         
     | 
| 
      
 6 
     | 
    
         
            +
                include(Base::ObjectType)
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 9 
     | 
    
         
            +
                  extend(T::Sig)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  extend(T::Helpers)
         
     | 
| 
      
 11 
     | 
    
         
            +
                  include(OutputTypeShorthands)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  include(InputTypeShorthands)
         
     | 
| 
      
 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 
     | 
    
         
            +
                  sig { overridable.returns(T::Array[Directive]) }
         
     | 
| 
      
 36 
     | 
    
         
            +
                  def directives
         
     | 
| 
      
 37 
     | 
    
         
            +
                    []
         
     | 
| 
      
 38 
     | 
    
         
            +
                  end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                  private
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                  sig { params(name: Symbol).returns(T.untyped) }
         
     | 
| 
      
 43 
     | 
    
         
            +
                  def const_missing(name)
         
     | 
| 
      
 44 
     | 
    
         
            +
                    if name == :Interface
         
     | 
| 
      
 45 
     | 
    
         
            +
                      definition
         
     | 
| 
      
 46 
     | 
    
         
            +
                      const_get(:Interface)
         
     | 
| 
      
 47 
     | 
    
         
            +
                    else
         
     | 
| 
      
 48 
     | 
    
         
            +
                      super
         
     | 
| 
      
 49 
     | 
    
         
            +
                    end
         
     | 
| 
      
 50 
     | 
    
         
            +
                  end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                  sig { override.returns(ObjectTypeDefinition) }
         
     | 
| 
      
 53 
     | 
    
         
            +
                  def definition
         
     | 
| 
      
 54 
     | 
    
         
            +
                    @definition ||= T.let(nil, T.nilable(ObjectTypeDefinition))
         
     | 
| 
      
 55 
     | 
    
         
            +
                    @definition ||= begin
         
     | 
| 
      
 56 
     | 
    
         
            +
                      graphql_name = self.graphql_name
         
     | 
| 
      
 57 
     | 
    
         
            +
                      field_definitions = self.field_definitions + [Builtin.typename_field_definition]
         
     | 
| 
      
 58 
     | 
    
         
            +
                      interface_implementations = self.interface_implementations
         
     | 
| 
      
 59 
     | 
    
         
            +
                      interface = Module.new do |mod|
         
     | 
| 
      
 60 
     | 
    
         
            +
                        field_definitions.each do |field_definition|
         
     | 
| 
      
 61 
     | 
    
         
            +
                          mod.define_method(field_definition.resolver_method_name) { graphql_name }
         
     | 
| 
      
 62 
     | 
    
         
            +
                        end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                        interface_implementations.each do |interface_implementation|
         
     | 
| 
      
 65 
     | 
    
         
            +
                          mod.include(T.cast(interface_implementation.interface, T.class_of(InterfaceType)).const_get(:Interface))
         
     | 
| 
      
 66 
     | 
    
         
            +
                        end
         
     | 
| 
      
 67 
     | 
    
         
            +
                      end
         
     | 
| 
      
 68 
     | 
    
         
            +
                      const_set(:Interface, interface)
         
     | 
| 
      
 69 
     | 
    
         
            +
                      ObjectTypeDefinition.new(
         
     | 
| 
      
 70 
     | 
    
         
            +
                        name: graphql_name,
         
     | 
| 
      
 71 
     | 
    
         
            +
                        description:,
         
     | 
| 
      
 72 
     | 
    
         
            +
                        field_definitions:,
         
     | 
| 
      
 73 
     | 
    
         
            +
                        interface_implementations:,
         
     | 
| 
      
 74 
     | 
    
         
            +
                        directives:,
         
     | 
| 
      
 75 
     | 
    
         
            +
                        ruby_class: self,
         
     | 
| 
      
 76 
     | 
    
         
            +
                      )
         
     | 
| 
      
 77 
     | 
    
         
            +
                    end
         
     | 
| 
      
 78 
     | 
    
         
            +
                  end
         
     | 
| 
      
 79 
     | 
    
         
            +
                end
         
     | 
| 
      
 80 
     | 
    
         
            +
              end
         
     | 
| 
      
 81 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # typed: strict
         
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module Bluejay
         
     | 
| 
      
 5 
     | 
    
         
            +
              module OutputTypeShorthands
         
     | 
| 
      
 6 
     | 
    
         
            +
                extend(T::Sig)
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                sig { params(t: BaseOutputType).returns(OutputType) }
         
     | 
| 
      
 9 
     | 
    
         
            +
                def ot(t)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  OutputType.new(type: t, required: false)
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                sig { params(t: BaseOutputType).returns(OutputType) }
         
     | 
| 
      
 14 
     | 
    
         
            +
                def ot!(t)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  OutputType.new(type: t, required: true)
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                sig { params(t: OutputType).returns(OutputType) }
         
     | 
| 
      
 19 
     | 
    
         
            +
                def lot(t)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  OutputType.list(type: t, required: false)
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                sig { params(t: OutputType).returns(OutputType) }
         
     | 
| 
      
 24 
     | 
    
         
            +
                def lot!(t)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  OutputType.list(type: t, required: true)
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,64 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # typed: strict
         
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module Bluejay
         
     | 
| 
      
 5 
     | 
    
         
            +
              class QueryRoot < ObjectType
         
     | 
| 
      
 6 
     | 
    
         
            +
                include(Base::QueryRoot)
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 9 
     | 
    
         
            +
                  extend(T::Sig)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  extend(T::Helpers)
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  abstract!
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  private
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  sig { override.returns(ObjectTypeDefinition) }
         
     | 
| 
      
 17 
     | 
    
         
            +
                  def definition
         
     | 
| 
      
 18 
     | 
    
         
            +
                    @definition ||= T.let(nil, T.nilable(ObjectTypeDefinition))
         
     | 
| 
      
 19 
     | 
    
         
            +
                    @definition ||= begin
         
     | 
| 
      
 20 
     | 
    
         
            +
                      # TODO: reduce duplication with ObjectType.definition
         
     | 
| 
      
 21 
     | 
    
         
            +
                      graphql_name = self.graphql_name
         
     | 
| 
      
 22 
     | 
    
         
            +
                      field_definitions = self.field_definitions + [Builtin.typename_field_definition]
         
     | 
| 
      
 23 
     | 
    
         
            +
                      interface_implementations = self.interface_implementations
         
     | 
| 
      
 24 
     | 
    
         
            +
                      interface = Module.new do |mod|
         
     | 
| 
      
 25 
     | 
    
         
            +
                        field_definitions.each do |field_definition|
         
     | 
| 
      
 26 
     | 
    
         
            +
                          mod.define_method(field_definition.resolver_method_name) { graphql_name }
         
     | 
| 
      
 27 
     | 
    
         
            +
                        end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                        interface_implementations.each do |interface_implementation|
         
     | 
| 
      
 30 
     | 
    
         
            +
                          mod.include(T.cast(interface_implementation.interface, T.class_of(InterfaceType)).const_get(:Interface))
         
     | 
| 
      
 31 
     | 
    
         
            +
                        end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                        mod.define_method(:resolve_schema) { |schema_class:| schema_class.send(:definition) }
         
     | 
| 
      
 34 
     | 
    
         
            +
                        mod.define_method(:resolve_type) do |name:, schema_class:|
         
     | 
| 
      
 35 
     | 
    
         
            +
                          schema_class.send(:definition).type(name)
         
     | 
| 
      
 36 
     | 
    
         
            +
                        end
         
     | 
| 
      
 37 
     | 
    
         
            +
                      end
         
     | 
| 
      
 38 
     | 
    
         
            +
                      const_set(:Interface, interface)
         
     | 
| 
      
 39 
     | 
    
         
            +
                      introspection_field_definitions = [
         
     | 
| 
      
 40 
     | 
    
         
            +
                        FieldDefinition.new(
         
     | 
| 
      
 41 
     | 
    
         
            +
                          name: "__schema",
         
     | 
| 
      
 42 
     | 
    
         
            +
                          type: ot!(Builtin::ObjectTypes::Schema),
         
     | 
| 
      
 43 
     | 
    
         
            +
                          resolver_method_name: "resolve_schema",
         
     | 
| 
      
 44 
     | 
    
         
            +
                        ),
         
     | 
| 
      
 45 
     | 
    
         
            +
                        FieldDefinition.new(
         
     | 
| 
      
 46 
     | 
    
         
            +
                          name: "__type",
         
     | 
| 
      
 47 
     | 
    
         
            +
                          argument_definitions: [InputValueDefinition.new(name: "name", type: it!(Scalar::String))],
         
     | 
| 
      
 48 
     | 
    
         
            +
                          type: ot(Builtin::ObjectTypes::Type),
         
     | 
| 
      
 49 
     | 
    
         
            +
                          resolver_method_name: "resolve_type",
         
     | 
| 
      
 50 
     | 
    
         
            +
                        ),
         
     | 
| 
      
 51 
     | 
    
         
            +
                      ]
         
     | 
| 
      
 52 
     | 
    
         
            +
                      ObjectTypeDefinition.new(
         
     | 
| 
      
 53 
     | 
    
         
            +
                        name: graphql_name,
         
     | 
| 
      
 54 
     | 
    
         
            +
                        description:,
         
     | 
| 
      
 55 
     | 
    
         
            +
                        field_definitions: field_definitions + introspection_field_definitions,
         
     | 
| 
      
 56 
     | 
    
         
            +
                        interface_implementations:,
         
     | 
| 
      
 57 
     | 
    
         
            +
                        directives:,
         
     | 
| 
      
 58 
     | 
    
         
            +
                        ruby_class: self,
         
     | 
| 
      
 59 
     | 
    
         
            +
                      )
         
     | 
| 
      
 60 
     | 
    
         
            +
                    end
         
     | 
| 
      
 61 
     | 
    
         
            +
                  end
         
     | 
| 
      
 62 
     | 
    
         
            +
                end
         
     | 
| 
      
 63 
     | 
    
         
            +
              end
         
     | 
| 
      
 64 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,91 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # typed: strict
         
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module Bluejay
         
     | 
| 
      
 5 
     | 
    
         
            +
              class Schema
         
     | 
| 
      
 6 
     | 
    
         
            +
                extend(Finalize)
         
     | 
| 
      
 7 
     | 
    
         
            +
                include(Base::Schema)
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 10 
     | 
    
         
            +
                  extend(T::Sig)
         
     | 
| 
      
 11 
     | 
    
         
            +
                  extend(T::Helpers)
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  abstract!
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                  sig { overridable.returns(T.nilable(String)) }
         
     | 
| 
      
 16 
     | 
    
         
            +
                  def description
         
     | 
| 
      
 17 
     | 
    
         
            +
                    nil
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  sig { abstract.returns(T.class_of(QueryRoot)) }
         
     | 
| 
      
 21 
     | 
    
         
            +
                  def query; end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                  sig { overridable.returns(T.nilable(T.class_of(ObjectType))) }
         
     | 
| 
      
 24 
     | 
    
         
            +
                  def mutation
         
     | 
| 
      
 25 
     | 
    
         
            +
                    nil
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  sig { overridable.returns(T::Array[Directive]) }
         
     | 
| 
      
 29 
     | 
    
         
            +
                  def directives
         
     | 
| 
      
 30 
     | 
    
         
            +
                    []
         
     | 
| 
      
 31 
     | 
    
         
            +
                  end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                  sig do
         
     | 
| 
      
 34 
     | 
    
         
            +
                    params(
         
     | 
| 
      
 35 
     | 
    
         
            +
                      query: String,
         
     | 
| 
      
 36 
     | 
    
         
            +
                      initial_value: Object,
         
     | 
| 
      
 37 
     | 
    
         
            +
                      operation_name: T.nilable(String),
         
     | 
| 
      
 38 
     | 
    
         
            +
                      variables: T::Hash[String, T.untyped],
         
     | 
| 
      
 39 
     | 
    
         
            +
                    ).returns(ExecutionResult)
         
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
                  def execute(query:, initial_value:, operation_name: nil, variables: {})
         
     | 
| 
      
 42 
     | 
    
         
            +
                    definition.execute(query, operation_name, variables, initial_value)
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                  sig { params(query: String).returns(T::Array[ValidationError]) }
         
     | 
| 
      
 46 
     | 
    
         
            +
                  def validate_query(query:)
         
     | 
| 
      
 47 
     | 
    
         
            +
                    definition.validate_query(query)
         
     | 
| 
      
 48 
     | 
    
         
            +
                  end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                  sig { returns(String) }
         
     | 
| 
      
 51 
     | 
    
         
            +
                  def to_definition
         
     | 
| 
      
 52 
     | 
    
         
            +
                    definition.to_definition
         
     | 
| 
      
 53 
     | 
    
         
            +
                  end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                  protected
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                  sig(:final) { override.void }
         
     | 
| 
      
 58 
     | 
    
         
            +
                  def finalize
         
     | 
| 
      
 59 
     | 
    
         
            +
                    definition
         
     | 
| 
      
 60 
     | 
    
         
            +
                  end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                  private
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                  sig { params(name: Symbol).returns(T.untyped) }
         
     | 
| 
      
 65 
     | 
    
         
            +
                  def const_missing(name)
         
     | 
| 
      
 66 
     | 
    
         
            +
                    if name == :Root
         
     | 
| 
      
 67 
     | 
    
         
            +
                      definition
         
     | 
| 
      
 68 
     | 
    
         
            +
                      const_get(:Root)
         
     | 
| 
      
 69 
     | 
    
         
            +
                    else
         
     | 
| 
      
 70 
     | 
    
         
            +
                      super
         
     | 
| 
      
 71 
     | 
    
         
            +
                    end
         
     | 
| 
      
 72 
     | 
    
         
            +
                  end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                  sig { override.returns(SchemaDefinition) }
         
     | 
| 
      
 75 
     | 
    
         
            +
                  def definition
         
     | 
| 
      
 76 
     | 
    
         
            +
                    @definition ||= T.let(nil, T.nilable(SchemaDefinition))
         
     | 
| 
      
 77 
     | 
    
         
            +
                    @definition ||= begin
         
     | 
| 
      
 78 
     | 
    
         
            +
                      mutation = self.mutation
         
     | 
| 
      
 79 
     | 
    
         
            +
                      interface = Module.new do |mod|
         
     | 
| 
      
 80 
     | 
    
         
            +
                        mod.define_method(:query) {}
         
     | 
| 
      
 81 
     | 
    
         
            +
                        if mutation
         
     | 
| 
      
 82 
     | 
    
         
            +
                          mod.define_method(:mutation) {}
         
     | 
| 
      
 83 
     | 
    
         
            +
                        end
         
     | 
| 
      
 84 
     | 
    
         
            +
                      end
         
     | 
| 
      
 85 
     | 
    
         
            +
                      const_set(:Root, interface)
         
     | 
| 
      
 86 
     | 
    
         
            +
                      SchemaDefinition.new(description:, query:, mutation:, directives:, ruby_class: self)
         
     | 
| 
      
 87 
     | 
    
         
            +
                    end
         
     | 
| 
      
 88 
     | 
    
         
            +
                  end
         
     | 
| 
      
 89 
     | 
    
         
            +
                end
         
     | 
| 
      
 90 
     | 
    
         
            +
              end
         
     | 
| 
      
 91 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,50 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # typed: strict
         
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module Bluejay
         
     | 
| 
      
 5 
     | 
    
         
            +
              class UnionType
         
     | 
| 
      
 6 
     | 
    
         
            +
                include(Base::UnionType)
         
     | 
| 
      
 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 
     | 
    
         
            +
                  sig { overridable.returns(T::Array[Directive]) }
         
     | 
| 
      
 29 
     | 
    
         
            +
                  def directives
         
     | 
| 
      
 30 
     | 
    
         
            +
                    []
         
     | 
| 
      
 31 
     | 
    
         
            +
                  end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                  private
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                  sig { override.returns(UnionTypeDefinition) }
         
     | 
| 
      
 36 
     | 
    
         
            +
                  def definition
         
     | 
| 
      
 37 
     | 
    
         
            +
                    @definition ||= T.let(
         
     | 
| 
      
 38 
     | 
    
         
            +
                      UnionTypeDefinition.new(
         
     | 
| 
      
 39 
     | 
    
         
            +
                        name: graphql_name,
         
     | 
| 
      
 40 
     | 
    
         
            +
                        description:,
         
     | 
| 
      
 41 
     | 
    
         
            +
                        member_types:,
         
     | 
| 
      
 42 
     | 
    
         
            +
                        directives:,
         
     | 
| 
      
 43 
     | 
    
         
            +
                        field_definitions: [Builtin.typename_field_definition],
         
     | 
| 
      
 44 
     | 
    
         
            +
                      ),
         
     | 
| 
      
 45 
     | 
    
         
            +
                      T.nilable(UnionTypeDefinition),
         
     | 
| 
      
 46 
     | 
    
         
            +
                    )
         
     | 
| 
      
 47 
     | 
    
         
            +
                  end
         
     | 
| 
      
 48 
     | 
    
         
            +
                end
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
      
 50 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/bluejay.rb
    ADDED
    
    | 
         @@ -0,0 +1,45 @@ 
     | 
|
| 
      
 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"
         
     | 
| 
      
 8 
     | 
    
         
            +
            require_relative "bluejay/base_input_type"
         
     | 
| 
      
 9 
     | 
    
         
            +
            require_relative "bluejay/base_output_type"
         
     | 
| 
      
 10 
     | 
    
         
            +
            require_relative "bluejay/input_type_shorthands"
         
     | 
| 
      
 11 
     | 
    
         
            +
            require_relative "bluejay/output_type_shorthands"
         
     | 
| 
      
 12 
     | 
    
         
            +
            require_relative "bluejay/json_value"
         
     | 
| 
      
 13 
     | 
    
         
            +
            require_relative "bluejay/custom_scalar_type"
         
     | 
| 
      
 14 
     | 
    
         
            +
            require_relative "bluejay/directive"
         
     | 
| 
      
 15 
     | 
    
         
            +
            require_relative "bluejay/enum_type"
         
     | 
| 
      
 16 
     | 
    
         
            +
            require_relative "bluejay/interface_type"
         
     | 
| 
      
 17 
     | 
    
         
            +
            require_relative "bluejay/input_object_type"
         
     | 
| 
      
 18 
     | 
    
         
            +
            require_relative "bluejay/object_type"
         
     | 
| 
      
 19 
     | 
    
         
            +
            require_relative "bluejay/query_root"
         
     | 
| 
      
 20 
     | 
    
         
            +
            require_relative "bluejay/schema"
         
     | 
| 
      
 21 
     | 
    
         
            +
            require_relative "bluejay/union_type"
         
     | 
| 
      
 22 
     | 
    
         
            +
            require_relative "bluejay/errors"
         
     | 
| 
      
 23 
     | 
    
         
            +
            require_relative "bluejay/builtin"
         
     | 
| 
      
 24 
     | 
    
         
            +
            require_relative "bluejay/builtin/directives/deprecated"
         
     | 
| 
      
 25 
     | 
    
         
            +
            require_relative "bluejay/builtin/directives/include"
         
     | 
| 
      
 26 
     | 
    
         
            +
            require_relative "bluejay/builtin/directives/skip"
         
     | 
| 
      
 27 
     | 
    
         
            +
            require_relative "bluejay/builtin/directives/specified_by"
         
     | 
| 
      
 28 
     | 
    
         
            +
            require_relative "bluejay/builtin/enum_types/directive_location"
         
     | 
| 
      
 29 
     | 
    
         
            +
            require_relative "bluejay/builtin/enum_types/type_kind"
         
     | 
| 
      
 30 
     | 
    
         
            +
            require_relative "bluejay/builtin/object_types/enum_value"
         
     | 
| 
      
 31 
     | 
    
         
            +
            require_relative "bluejay/builtin/object_types/type"
         
     | 
| 
      
 32 
     | 
    
         
            +
            require_relative "bluejay/builtin/object_types/input_value"
         
     | 
| 
      
 33 
     | 
    
         
            +
            require_relative "bluejay/builtin/object_types/field"
         
     | 
| 
      
 34 
     | 
    
         
            +
            require_relative "bluejay/builtin/object_types/directive"
         
     | 
| 
      
 35 
     | 
    
         
            +
            require_relative "bluejay/builtin/object_types/schema"
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            begin
         
     | 
| 
      
 38 
     | 
    
         
            +
              RUBY_VERSION =~ /(\d+\.\d+)/
         
     | 
| 
      
 39 
     | 
    
         
            +
              require "bluejay/#{Regexp.last_match(1)}/bluejay_rb"
         
     | 
| 
      
 40 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 41 
     | 
    
         
            +
              require "bluejay/bluejay_rb"
         
     | 
| 
      
 42 
     | 
    
         
            +
            end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            module Bluejay
         
     | 
| 
      
 45 
     | 
    
         
            +
            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
         
     |