Skip to content

Commit

Permalink
Merge pull request #5195 from rmosolgo/resolver-inherit-description
Browse files Browse the repository at this point in the history
Make resolvers inherit description from superclass
  • Loading branch information
rmosolgo authored Dec 27, 2024
2 parents 1b1d382 + c64dec8 commit ca9ff0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/graphql/schema/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Resolver
include Schema::Member::GraphQLTypeNames
# Really we only need description & comment from here, but:
extend Schema::Member::BaseDSLMethods
extend Member::BaseDSLMethods::ConfigurationExtension
extend GraphQL::Schema::Member::HasArguments
extend GraphQL::Schema::Member::HasValidators
include Schema::Member::HasPath
Expand Down
10 changes: 10 additions & 0 deletions spec/graphql/schema/resolver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class Resolver3 < Resolver1
class Resolver4 < BaseResolver
type Integer, null: false

description "Adds object.value to ast_node.name.size"

extras [:ast_node]
def resolve(ast_node:)
object.value + ast_node.name.size
Expand Down Expand Up @@ -724,6 +726,14 @@ def exec_query(*args, **kwargs)
end
end

describe "description" do
it "is inherited" do
expected_desc = "Adds object.value to ast_node.name.size"
assert_equal expected_desc, ResolverTest::Resolver4.description
assert_equal expected_desc, ResolverTest::Resolver5.description
end
end

describe "when applied to a field" do
it "gets the field's description" do
assert_nil ResolverTest::Schema.find("Query.resolver3").description
Expand Down

0 comments on commit ca9ff0e

Please sign in to comment.