oriole 0.1.0.alpha.0

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 (80) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +56 -0
  3. data/.rubocop.yml +32 -0
  4. data/.ruby-version +1 -0
  5. data/CHANGELOG.md +1 -0
  6. data/Gemfile +20 -0
  7. data/Gemfile.lock +121 -0
  8. data/LICENSE +21 -0
  9. data/README.md +84 -0
  10. data/Rakefile +12 -0
  11. data/bench/bench.rb +35 -0
  12. data/bench/execute.rb +66 -0
  13. data/bench/schemas/bluejay.rb +149 -0
  14. data/bench/schemas/models.rb +216 -0
  15. data/bench/schemas/oriole.rb +144 -0
  16. data/bin/console +15 -0
  17. data/bin/setup +8 -0
  18. data/bin/style +2 -0
  19. data/bin/tapioca +27 -0
  20. data/bin/typecheck +2 -0
  21. data/lib/oriole/builtin_scalar_definition.rb +53 -0
  22. data/lib/oriole/definition/abstract/definition.rb +21 -0
  23. data/lib/oriole/definition/abstract/field_definition.rb +22 -0
  24. data/lib/oriole/definition/abstract/object_type_definition.rb +21 -0
  25. data/lib/oriole/definition/abstract/schema_definition.rb +18 -0
  26. data/lib/oriole/definition/abstract/visibility.rb +18 -0
  27. data/lib/oriole/definition/base_output_type.rb +13 -0
  28. data/lib/oriole/definition/field_definition.rb +27 -0
  29. data/lib/oriole/definition/object_type.rb +40 -0
  30. data/lib/oriole/definition/output_type.rb +79 -0
  31. data/lib/oriole/definition/schema.rb +45 -0
  32. data/lib/oriole/definition/visibility_scoped/object_type_definition.rb +62 -0
  33. data/lib/oriole/definition/visibility_scoped/schema_definition.rb +26 -0
  34. data/lib/oriole/execution/coerce_result.rb +16 -0
  35. data/lib/oriole/execution/engine.rb +207 -0
  36. data/lib/oriole/version.rb +6 -0
  37. data/lib/oriole.rb +14 -0
  38. data/oriole.gemspec +38 -0
  39. data/rakelib/bench.rake +69 -0
  40. data/sorbet/config +5 -0
  41. data/sorbet/rbi/annotations/rainbow.rbi +269 -0
  42. data/sorbet/rbi/gems/ast@2.4.2.rbi +584 -0
  43. data/sorbet/rbi/gems/base64@0.1.1.rbi +172 -0
  44. data/sorbet/rbi/gems/bluejay@0.1.0.alpha.2-a45c1b3b47aa4524f94bbe03db5ff1ae792afd09.rbi +1206 -0
  45. data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +1083 -0
  46. data/sorbet/rbi/gems/erubi@1.12.0.rbi +145 -0
  47. data/sorbet/rbi/gems/json@2.6.3.rbi +1533 -0
  48. data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +14237 -0
  49. data/sorbet/rbi/gems/minitest@5.19.0.rbi +1491 -0
  50. data/sorbet/rbi/gems/netrc@0.11.0.rbi +158 -0
  51. data/sorbet/rbi/gems/parallel@1.23.0.rbi +273 -0
  52. data/sorbet/rbi/gems/parser@3.2.2.3.rbi +7253 -0
  53. data/sorbet/rbi/gems/prettier_print@1.2.1.rbi +951 -0
  54. data/sorbet/rbi/gems/racc@1.7.1.rbi +161 -0
  55. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +402 -0
  56. data/sorbet/rbi/gems/rake@13.0.6.rbi +3024 -0
  57. data/sorbet/rbi/gems/rbi@0.0.17.rbi +2972 -0
  58. data/sorbet/rbi/gems/regexp_parser@2.8.1.rbi +3749 -0
  59. data/sorbet/rbi/gems/rexml@3.2.6.rbi +4781 -0
  60. data/sorbet/rbi/gems/rubocop-ast@1.29.0.rbi +7006 -0
  61. data/sorbet/rbi/gems/rubocop-minitest@0.27.0.rbi +2371 -0
  62. data/sorbet/rbi/gems/rubocop-rake@0.6.0.rbi +328 -0
  63. data/sorbet/rbi/gems/rubocop-shopify@2.14.0.rbi +8 -0
  64. data/sorbet/rbi/gems/rubocop-sorbet@0.6.11.rbi +975 -0
  65. data/sorbet/rbi/gems/rubocop@1.56.1.rbi +56525 -0
  66. data/sorbet/rbi/gems/ruby-lsp@0.4.5.rbi +11 -0
  67. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1317 -0
  68. data/sorbet/rbi/gems/spoom@1.2.3.rbi +3203 -0
  69. data/sorbet/rbi/gems/syntax_tree@6.1.1.rbi +22855 -0
  70. data/sorbet/rbi/gems/tapioca@0.11.8.rbi +3349 -0
  71. data/sorbet/rbi/gems/thor@1.2.2.rbi +3965 -0
  72. data/sorbet/rbi/gems/tinygql@0.1.4.rbi +2363 -0
  73. data/sorbet/rbi/gems/unicode-display_width@2.4.2.rbi +65 -0
  74. data/sorbet/rbi/gems/unparser@0.6.8.rbi +4525 -0
  75. data/sorbet/rbi/gems/yard-sorbet@0.8.1.rbi +428 -0
  76. data/sorbet/rbi/gems/yard@0.9.34.rbi +18219 -0
  77. data/sorbet/rbi/gems/zeitwerk@2.6.11.rbi +999 -0
  78. data/sorbet/tapioca/config.yml +13 -0
  79. data/sorbet/tapioca/require.rb +5 -0
  80. metadata +208 -0
@@ -0,0 +1,216 @@
1
+ # typed: ignore
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "bluejay"
5
+
6
+ module Schemas
7
+ module Models
8
+ class DraftPosition < T::Struct
9
+ extend(T::Sig)
10
+ include(Schemas::Bluejay::DraftPosition::Interface)
11
+
12
+ const(:round, Integer)
13
+ const(:selection, Integer)
14
+ const(:year, Integer)
15
+ end
16
+
17
+ class Player < T::Struct
18
+ extend(T::Sig)
19
+ include(Schemas::Bluejay::Player::Interface)
20
+
21
+ const(:first_name, String)
22
+ const(:last_name, String)
23
+ const(:age, Integer)
24
+ const(:draft_position, T.nilable(DraftPosition))
25
+ end
26
+
27
+ class Team < T::Struct
28
+ extend(T::Sig)
29
+ include(Schemas::Bluejay::Team::Interface)
30
+
31
+ const(:name, String)
32
+ const(:city, String)
33
+ const(:players, T::Array[Player])
34
+
35
+ class << self
36
+ extend(T::Sig)
37
+
38
+ sig { returns(T::Array[Team]) }
39
+ def all
40
+ [
41
+ Team.new(
42
+ name: "Maple Leafs",
43
+ city: "Toronto",
44
+ players: [
45
+ Player.new(
46
+ first_name: "Auston",
47
+ last_name: "Matthews",
48
+ age: 25,
49
+ draft_position: DraftPosition.new(
50
+ round: 1,
51
+ selection: 1,
52
+ year: 2016,
53
+ ),
54
+ ),
55
+ Player.new(
56
+ first_name: "Mitch",
57
+ last_name: "Marner",
58
+ age: 25,
59
+ draft_position: DraftPosition.new(
60
+ round: 1,
61
+ selection: 4,
62
+ year: 2015,
63
+ ),
64
+ ),
65
+ Player.new(
66
+ first_name: "William",
67
+ last_name: "Nylander",
68
+ age: 26,
69
+ draft_position: DraftPosition.new(
70
+ round: 1,
71
+ selection: 8,
72
+ year: 2014,
73
+ ),
74
+ ),
75
+ Player.new(
76
+ first_name: "John",
77
+ last_name: "Tavares",
78
+ age: 32,
79
+ draft_position: DraftPosition.new(
80
+ round: 1,
81
+ selection: 1,
82
+ year: 2009,
83
+ ),
84
+ ),
85
+ ],
86
+ ),
87
+ Team.new(
88
+ name: "Bruins",
89
+ city: "Boston",
90
+ players: [
91
+ Player.new(
92
+ first_name: "Patrice",
93
+ last_name: "Bergeron",
94
+ age: 37,
95
+ ),
96
+ Player.new(
97
+ first_name: "Brad",
98
+ last_name: "Marchand",
99
+ age: 34,
100
+ ),
101
+ Player.new(
102
+ first_name: "David",
103
+ last_name: "Pastrňák",
104
+ age: 26,
105
+ ),
106
+ Player.new(
107
+ first_name: "Charlie",
108
+ last_name: "McAvoy",
109
+ age: 25,
110
+ ),
111
+ ],
112
+ ),
113
+ Team.new(
114
+ name: "Canadiens",
115
+ city: "Montréal",
116
+ players: [
117
+ Player.new(
118
+ first_name: "Nick",
119
+ last_name: "Suzuki",
120
+ age: 23,
121
+ ),
122
+ Player.new(
123
+ first_name: "Cole",
124
+ last_name: "Caufield",
125
+ age: 22,
126
+ ),
127
+ Player.new(
128
+ first_name: "Kirby",
129
+ last_name: "Dach",
130
+ age: 21,
131
+ ),
132
+ Player.new(
133
+ first_name: "Sean",
134
+ last_name: "Monahan",
135
+ age: 28,
136
+ ),
137
+ ],
138
+ ),
139
+ Team.new(
140
+ name: "Blackhawks",
141
+ city: "Chicago",
142
+ players: [],
143
+ ),
144
+ Team.new(
145
+ name: "Red Wings",
146
+ city: "Detroit",
147
+ players: [],
148
+ ),
149
+ Team.new(
150
+ name: "Rangers",
151
+ city: "New York",
152
+ players: [
153
+ Player.new(
154
+ first_name: "Adam",
155
+ last_name: "Fox",
156
+ age: 24,
157
+ ),
158
+ Player.new(
159
+ first_name: "Artemi",
160
+ last_name: "Panarin",
161
+ age: 31,
162
+ ),
163
+ Player.new(
164
+ first_name: "Alexis",
165
+ last_name: "Lafrenière",
166
+ age: 21,
167
+ ),
168
+ Player.new(
169
+ first_name: "Igor",
170
+ last_name: "Shesterkin",
171
+ age: 27,
172
+ ),
173
+ ],
174
+ ),
175
+ ]
176
+ end
177
+ end
178
+ end
179
+
180
+ class QueryRoot < T::Struct
181
+ extend(T::Sig)
182
+ include(Schemas::Bluejay::QueryRoot::Interface)
183
+
184
+ const(:teams, T::Array[Team])
185
+ end
186
+
187
+ class PlayersCreate < T::Struct
188
+ const(:count, Integer)
189
+ end
190
+
191
+ class MutationRoot
192
+ class << self
193
+ extend(T::Sig)
194
+
195
+ include(Schemas::Bluejay::MutationRoot::Interface)
196
+
197
+ sig { params(players: T::Array[Schemas::Bluejay::PlayerInput]).returns(PlayersCreate) }
198
+ def players_create(players:)
199
+ PlayersCreate.new(
200
+ count: players.length,
201
+ )
202
+ end
203
+ end
204
+ end
205
+
206
+ class SchemaRoot < T::Struct
207
+ extend(T::Sig)
208
+ include(Schemas::Bluejay::Schema::Root)
209
+
210
+ const(:query, QueryRoot)
211
+
212
+ sig { override.returns(Schemas::Bluejay::MutationRoot::Interface) }
213
+ def mutation = MutationRoot
214
+ end
215
+ end
216
+ end
@@ -0,0 +1,144 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Schemas
5
+ module Oriole
6
+ class DraftPosition < ::Oriole::Definition::ObjectType
7
+ class << self
8
+ extend(T::Sig)
9
+
10
+ sig { override.returns(T::Array[::Oriole::Definition::FieldDefinition]) }
11
+ def field_definitions
12
+ @field_definitions ||= T.let(
13
+ [
14
+ ::Oriole::Definition::FieldDefinition.new(
15
+ graphql_name: "__typename",
16
+ type: ::Oriole::Definition::OutputType.named!(::Oriole::BuiltinScalarDefinition::String),
17
+ method_name: "resolve_typename",
18
+ ),
19
+ ::Oriole::Definition::FieldDefinition.new(
20
+ graphql_name: "round",
21
+ type: ::Oriole::Definition::OutputType.named!(::Oriole::BuiltinScalarDefinition::Int),
22
+ ),
23
+ ::Oriole::Definition::FieldDefinition.new(
24
+ graphql_name: "selection",
25
+ type: ::Oriole::Definition::OutputType.named!(::Oriole::BuiltinScalarDefinition::Int),
26
+ ),
27
+ ::Oriole::Definition::FieldDefinition.new(
28
+ graphql_name: "year",
29
+ type: ::Oriole::Definition::OutputType.named!(::Oriole::BuiltinScalarDefinition::Int),
30
+ ),
31
+ ],
32
+ T.nilable(T::Array[::Oriole::Definition::FieldDefinition]),
33
+ )
34
+ end
35
+ end
36
+ end
37
+
38
+ class Player < ::Oriole::Definition::ObjectType
39
+ class << self
40
+ extend(T::Sig)
41
+
42
+ sig { override.returns(T::Array[::Oriole::Definition::FieldDefinition]) }
43
+ def field_definitions
44
+ @field_definitions ||= T.let(
45
+ [
46
+ ::Oriole::Definition::FieldDefinition.new(
47
+ graphql_name: "__typename",
48
+ type: ::Oriole::Definition::OutputType.named!(::Oriole::BuiltinScalarDefinition::String),
49
+ method_name: "resolve_typename",
50
+ ),
51
+ ::Oriole::Definition::FieldDefinition.new(
52
+ graphql_name: "firstName",
53
+ type: ::Oriole::Definition::OutputType.named!(::Oriole::BuiltinScalarDefinition::String),
54
+ method_name: "first_name",
55
+ ),
56
+ ::Oriole::Definition::FieldDefinition.new(
57
+ graphql_name: "lastName",
58
+ type: ::Oriole::Definition::OutputType.named!(::Oriole::BuiltinScalarDefinition::String),
59
+ method_name: "last_name",
60
+ ),
61
+ ::Oriole::Definition::FieldDefinition.new(
62
+ graphql_name: "age",
63
+ type: ::Oriole::Definition::OutputType.named!(::Oriole::BuiltinScalarDefinition::Int),
64
+ ),
65
+ ::Oriole::Definition::FieldDefinition.new(
66
+ graphql_name: "draftPosition",
67
+ type: ::Oriole::Definition::OutputType.named(DraftPosition),
68
+ method_name: "draft_position",
69
+ ),
70
+ ],
71
+ T.nilable(T::Array[::Oriole::Definition::FieldDefinition]),
72
+ )
73
+ end
74
+ end
75
+ end
76
+
77
+ class Team < ::Oriole::Definition::ObjectType
78
+ class << self
79
+ extend(T::Sig)
80
+
81
+ sig { override.returns(T::Array[::Oriole::Definition::FieldDefinition]) }
82
+ def field_definitions
83
+ @field_definitions ||= T.let(
84
+ [
85
+ ::Oriole::Definition::FieldDefinition.new(
86
+ graphql_name: "__typename",
87
+ type: ::Oriole::Definition::OutputType.named!(::Oriole::BuiltinScalarDefinition::String),
88
+ method_name: "resolve_typename",
89
+ ),
90
+ ::Oriole::Definition::FieldDefinition.new(
91
+ graphql_name: "name",
92
+ type: ::Oriole::Definition::OutputType.named!(::Oriole::BuiltinScalarDefinition::String),
93
+ ),
94
+ ::Oriole::Definition::FieldDefinition.new(
95
+ graphql_name: "city",
96
+ type: ::Oriole::Definition::OutputType.named!(::Oriole::BuiltinScalarDefinition::String),
97
+ ),
98
+ ::Oriole::Definition::FieldDefinition.new(
99
+ graphql_name: "players",
100
+ type: ::Oriole::Definition::OutputType.list!(::Oriole::Definition::OutputType.named!(Player)),
101
+ ),
102
+ ],
103
+ T.nilable(T::Array[::Oriole::Definition::FieldDefinition]),
104
+ )
105
+ end
106
+ end
107
+ end
108
+
109
+ class QueryRoot < ::Oriole::Definition::ObjectType
110
+ class << self
111
+ extend(T::Sig)
112
+
113
+ sig { override.returns(T::Array[::Oriole::Definition::FieldDefinition]) }
114
+ def field_definitions
115
+ @field_definitions ||= T.let(
116
+ [
117
+ ::Oriole::Definition::FieldDefinition.new(
118
+ graphql_name: "__typename",
119
+ type: ::Oriole::Definition::OutputType.named!(::Oriole::BuiltinScalarDefinition::String),
120
+ method_name: "resolve_typename",
121
+ ),
122
+ ::Oriole::Definition::FieldDefinition.new(
123
+ graphql_name: "teams",
124
+ type: ::Oriole::Definition::OutputType.list!(::Oriole::Definition::OutputType.named!(Team)),
125
+ ),
126
+ ],
127
+ T.nilable(T::Array[::Oriole::Definition::FieldDefinition]),
128
+ )
129
+ end
130
+ end
131
+ end
132
+
133
+ class Schema < ::Oriole::Definition::Schema
134
+ class << self
135
+ extend(T::Sig)
136
+
137
+ sig { override.returns(T.class_of(::Oriole::Definition::ObjectType)) }
138
+ def query
139
+ QueryRoot
140
+ end
141
+ end
142
+ end
143
+ end
144
+ end
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "oriole"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bin/style ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env bash
2
+ bundle exec rubocop "$@"
data/bin/tapioca ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'tapioca' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
+
13
+ bundle_binstub = File.expand_path("bundle", __dir__)
14
+
15
+ if File.file?(bundle_binstub)
16
+ if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
17
+ load(bundle_binstub)
18
+ else
19
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21
+ end
22
+ end
23
+
24
+ require "rubygems"
25
+ require "bundler/setup"
26
+
27
+ load Gem.bin_path("tapioca", "tapioca")
data/bin/typecheck ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env bash
2
+ bundle exec srb tc "$@"
@@ -0,0 +1,53 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Oriole
5
+ class BuiltinScalarDefinition < T::Enum
6
+ extend(T::Sig)
7
+ include(Execution::CoerceResult)
8
+
9
+ enums do
10
+ Int = new
11
+ Float = new
12
+ String = new
13
+ Boolean = new
14
+ ID = new
15
+ end
16
+
17
+ sig { override.params(result: Object).returns(Object) }
18
+ def coerce_result(result:)
19
+ case self
20
+ when Int
21
+ if result.is_a?(Integer) && result < T.cast(2**31, Integer) && result >= T.cast(-2**31, Integer)
22
+ result
23
+ else
24
+ raise "Value not an i32"
25
+ end
26
+ when Float
27
+ if result.is_a?(Numeric) && result.finite?
28
+ result
29
+ else
30
+ raise "Value not a finite float"
31
+ end
32
+ when String
33
+ if result.is_a?(::String)
34
+ result
35
+ else
36
+ raise "Value not a string"
37
+ end
38
+ when Boolean
39
+ if result == true || result == false
40
+ result
41
+ else
42
+ raise "Value not a boolean"
43
+ end
44
+ when ID
45
+ if result.is_a?(::String) || result.is_a?(Integer)
46
+ result
47
+ else
48
+ raise "Value not a string or integer"
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,21 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Oriole
5
+ module Definition
6
+ module Abstract
7
+ module Definition
8
+ extend(T::Sig)
9
+ extend(T::Helpers)
10
+
11
+ abstract!
12
+
13
+ sig { abstract.returns(String) }
14
+ def graphql_name; end
15
+
16
+ sig { abstract.returns(T.nilable(String)) }
17
+ def description; end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Oriole
5
+ module Definition
6
+ module Abstract
7
+ module FieldDefinition
8
+ extend(T::Sig)
9
+ extend(T::Helpers)
10
+ include(Definition)
11
+
12
+ abstract!
13
+
14
+ sig { abstract.returns(OutputType) }
15
+ def type; end
16
+
17
+ sig { abstract.returns(String) }
18
+ def resolver_method_name; end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Oriole
5
+ module Definition
6
+ module Abstract
7
+ module ObjectTypeDefinition
8
+ extend(T::Sig)
9
+ extend(T::Helpers)
10
+ include(Definition)
11
+
12
+ requires_ancestor { Kernel }
13
+
14
+ abstract!
15
+
16
+ sig { abstract.returns(T::Array[FieldDefinition]) }
17
+ def field_definitions; end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Oriole
5
+ module Definition
6
+ module Abstract
7
+ module SchemaDefinition
8
+ extend(T::Sig)
9
+ extend(T::Helpers)
10
+
11
+ abstract!
12
+
13
+ sig { abstract.returns(ObjectTypeDefinition) }
14
+ def query; end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Oriole
5
+ module Definition
6
+ module Abstract
7
+ module Visibility
8
+ extend(T::Sig)
9
+ extend(T::Helpers)
10
+
11
+ abstract!
12
+
13
+ sig { abstract.params(context: Object).returns(T::Boolean) }
14
+ def visible?(context:); end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Oriole
5
+ module Definition
6
+ BaseOutputType = T.type_alias do
7
+ T.any(
8
+ BuiltinScalarDefinition,
9
+ Abstract::ObjectTypeDefinition,
10
+ )
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,27 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Oriole
5
+ module Definition
6
+ class FieldDefinition < T::Struct
7
+ extend(T::Sig)
8
+ include(Abstract::FieldDefinition)
9
+
10
+ const(:graphql_name, String)
11
+ const(:description, T.nilable(String))
12
+ const(:type, OutputType)
13
+ const(:visibility, T.nilable(Abstract::Visibility))
14
+ const(:method_name, T.nilable(String))
15
+
16
+ sig { params(context: Object).returns(T::Boolean) }
17
+ def visible?(context:)
18
+ @visibility ? @visibility.visible?(context: context) : true
19
+ end
20
+
21
+ sig { override.returns(String) }
22
+ def resolver_method_name
23
+ @method_name || @graphql_name
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,40 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Oriole
5
+ module Definition
6
+ class ObjectType
7
+ class << self
8
+ extend(T::Sig)
9
+ extend(T::Helpers)
10
+ include(Definition::Abstract::ObjectTypeDefinition)
11
+
12
+ abstract!
13
+
14
+ sig { overridable.returns(T.nilable(Abstract::Visibility)) }
15
+ def visibility
16
+ nil
17
+ end
18
+
19
+ sig { override.returns(String) }
20
+ def graphql_name
21
+ name&.split("::")&.last || "Anonymous"
22
+ end
23
+
24
+ sig { override.returns(T.nilable(String)) }
25
+ def description
26
+ end
27
+
28
+ sig { abstract.returns(T::Array[FieldDefinition]) }
29
+ def field_definitions; end
30
+
31
+ sig { params(context: Object).returns(T::Boolean) }
32
+ def visible?(context:)
33
+ visibility = self.visibility
34
+
35
+ visibility ? visibility.visible?(context: context) : true
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end