From c64dec812e04a354212f66d9dedfa4d385d8608c Mon Sep 17 00:00:00 2001 From: Robert Mosolgo Date: Thu, 26 Dec 2024 10:41:00 -0500 Subject: [PATCH] Make resolvers inherit description from superclass --- lib/graphql/schema/resolver.rb | 1 + spec/graphql/schema/resolver_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/graphql/schema/resolver.rb b/lib/graphql/schema/resolver.rb index 20a33d4131..39dac4b675 100644 --- a/lib/graphql/schema/resolver.rb +++ b/lib/graphql/schema/resolver.rb @@ -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 diff --git a/spec/graphql/schema/resolver_spec.rb b/spec/graphql/schema/resolver_spec.rb index 6b709fce1e..15696dca83 100644 --- a/spec/graphql/schema/resolver_spec.rb +++ b/spec/graphql/schema/resolver_spec.rb @@ -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 @@ -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