Skip to content

Commit a853d55

Browse files
committed
Migrate more tests
1 parent 4ce8f39 commit a853d55

3 files changed

Lines changed: 18 additions & 22 deletions

File tree

spec/graphql/schema/member/scoped_spec.rb

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
class ScopeSchema < GraphQL::Schema
66
class BaseObject < GraphQL::Schema::Object
77
class BaseField < GraphQL::Schema::Field
8-
# include GraphQL::Execution::Next::FieldCompatibility if TESTING_EXEC_NEXT
98
end
109
field_class BaseField
1110
end
@@ -86,21 +85,21 @@ def self.resolve_type(item, ctx)
8685
end
8786

8887
class Query < BaseObject
89-
field :items, [Item], null: false
88+
field :items, [Item], null: false, resolve_legacy_instance_method: true
9089
field :unscoped_items, [Item], null: false,
9190
scope: false,
92-
resolver_method: :items
91+
resolver_method: :items, resolve_legacy_instance_method: :items
9392

94-
field :nil_items, [Item]
93+
field :nil_items, [Item], resolve_legacy_instance_method: true
9594
def nil_items
9695
nil
9796
end
9897

9998
field :french_items, [FrenchItem], null: false,
100-
resolver_method: :items
99+
resolver_method: :items, resolve_legacy_instance_method: :items
101100

102101
field :items_connection, Item.connection_type, null: false,
103-
resolver_method: :items
102+
resolver_method: :items, resolve_legacy_instance_method: :items
104103

105104
def items
106105
[
@@ -109,15 +108,15 @@ def items
109108
]
110109
end
111110

112-
field :reauthorize_items, [ReauthorizeItem], resolver_method: :items
111+
field :reauthorize_items, [ReauthorizeItem], resolver_method: :items, resolve_legacy_instance_method: :items
113112

114-
field :things, [Thing], null: false
113+
field :things, [Thing], null: false, resolve_legacy_instance_method: true
115114
def things
116115
items + [OpenStruct.new(name: "Turbine")]
117116
end
118117

119-
field :lazy_items, [Item], null: false
120-
field :lazy_items_connection, Item.connection_type, null: false, resolver_method: :lazy_items
118+
field :lazy_items, [Item], null: false, resolve_legacy_instance_method: true
119+
field :lazy_items_connection, Item.connection_type, null: false, resolver_method: :lazy_items, resolve_legacy_instance_method: :lazy_items
121120
def lazy_items
122121
->() { items }
123122
end
@@ -315,7 +314,6 @@ def get_item_names_with_context(ctx, field_name: "items")
315314
class SkipAuthSchema < GraphQL::Schema
316315
class Book < GraphQL::Schema::Object
317316
class BaseField < GraphQL::Schema::Field
318-
# include(GraphQL::Execution::Next::FieldCompatibility) if TESTING_EXEC_NEXT
319317
end
320318
field_class(BaseField)
321319

@@ -329,7 +327,7 @@ def self.scope_items(list, ctx)
329327
list.dup # Skipping authorized objects requires a new object to be returned
330328
end
331329

332-
field :title, String
330+
field :title, String, hash_key: :title
333331
end
334332

335333
class SkipAuthorizationBook < Book

spec/graphql/schema/validator/validator_helpers.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def visible?(_ctx)
3232
end
3333

3434
base_field = Class.new(GraphQL::Schema::Field) do
35-
# include GraphQL::Execution::Next::FieldCompatibility
3635
argument_class(base_argument)
3736
end
3837

@@ -72,15 +71,15 @@ def resolve(input: :NO_INPUT)
7271
query_type = Class.new(GraphQL::Schema::Object) do
7372
graphql_name "Query"
7473
field_class(base_field)
75-
field :validated, arg_type do
74+
field :validated, arg_type, resolve_legacy_instance_method: true do
7675
argument :value, arg_type, required: false, validates: validates_config
7776
end
7877

7978
def validated(value: nil)
8079
value
8180
end
8281

83-
field :multi_validated, arg_type, validates: validates_config do
82+
field :multi_validated, arg_type, validates: validates_config, resolve_legacy_instance_method: true do
8483
argument :a, arg_type, required: false
8584
argument :b, arg_type, required: false
8685
argument :c, arg_type, required: false
@@ -92,7 +91,7 @@ def multi_validated(a: 0, b: 0, c: 0)
9291
a + b + c
9392
end
9493

95-
field :validated_input, arg_type do
94+
field :validated_input, arg_type, resolve_legacy_instance_method: true do
9695
argument :input, validated_input
9796
end
9897

@@ -102,7 +101,7 @@ def validated_input(input:)
102101

103102
field :validated_resolver, resolver: validated_resolver
104103
field :validated_arg_resolver, resolver: validated_arg_resolver
105-
field :list, [self], null: false
104+
field :list, [self], null: false, resolve_legacy_instance_method: true
106105

107106
def list
108107
[:a, :b, :c]

spec/graphql/schema/visibility_spec.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
describe GraphQL::Schema::Visibility do
55
class VisSchema < GraphQL::Schema
66
class BaseField < GraphQL::Schema::Field
7-
# include GraphQL::Execution::Next::FieldCompatibility if TESTING_EXEC_NEXT
87
def initialize(*args, admin_only: false, **kwargs, &block)
98
super(*args, **kwargs, &block)
109
@admin_only = admin_only
@@ -32,9 +31,9 @@ def self.admin_only(new_value = nil)
3231
end
3332

3433
class Product < BaseObject
35-
field :name, String
36-
field :price, Integer
37-
field :cost_of_goods_sold, Integer, admin_only: true
34+
field :name, String, hash_key: :name
35+
field :price, Integer, hash_key: :price
36+
field :cost_of_goods_sold, Integer, admin_only: true, hash_key: :cost_of_goods_sold
3837
end
3938

4039
class Widget < BaseObject
@@ -48,7 +47,7 @@ class WidgetKind < GraphQL::Schema::Enum
4847
end
4948

5049
class Query < BaseObject
51-
field :products, [Product]
50+
field :products, [Product], resolve_legacy_instance_method: true
5251
field :widget, Widget do
5352
argument :type, WidgetKind
5453
end

0 commit comments

Comments
 (0)