Skip to content

Commit 0a4dc15

Browse files
authored
Merge pull request rmosolgo#2383 from rmosolgo/fix-method-warning-again
Fix warning and method detection
2 parents fea515e + db9b22e commit 0a4dc15

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

lib/graphql/schema/field.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def initialize(type: nil, name: nil, owner: nil, null: nil, field: nil, function
205205

206206
# TODO: I think non-string/symbol hash keys are wrongly normalized (eg `1` will not work)
207207
method_name = method || hash_key || @underscored_name
208-
resolver_method ||= @underscored_name
208+
resolver_method ||= @underscored_name.to_sym
209209

210210
@method_str = method_name.to_s
211211
@method_sym = method_name.to_sym

lib/graphql/schema/member/has_fields.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def get_field(field_name)
5353
# @param field_defn [GraphQL::Schema::Field]
5454
# @return [void]
5555
def add_field(field_defn)
56-
if CONFLICT_FIELD_NAMES.include?(field_defn.method_sym)
57-
warn "#{self.graphql_name}'s `field :#{field_defn.name}` conflicts with a built-in method, use `resolver_method:` to pick a different resolver method for this field (for example, `resolver_method: :resolve_#{field_defn.method_sym}` and `def resolve_#{field_defn.method_sym}`)"
56+
if CONFLICT_FIELD_NAMES.include?(field_defn.resolver_method)
57+
warn "#{self.graphql_name}'s `field :#{field_defn.name}` conflicts with a built-in method, use `resolver_method:` to pick a different resolver method for this field (for example, `resolver_method: :resolve_#{field_defn.resolver_method}` and `def resolve_#{field_defn.resolver_method}`)"
5858
end
5959
own_fields[field_defn.name] = field_defn
6060
nil

spec/graphql/schema/object_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def call(o, a, c)
328328
assert_output "", "" do
329329
Class.new(GraphQL::Schema::Object) do
330330
graphql_name "X"
331-
field :method, String, null: true, method: :resolve_method
331+
field :method, String, null: true, resolver_method: :resolve_method
332332
end
333333
end
334334
end

0 commit comments

Comments
 (0)