From f4a9ec7ad16ba4a5748739a6a691ec5936d2cffb Mon Sep 17 00:00:00 2001 From: Robert Mosolgo Date: Thu, 7 Nov 2024 14:54:35 -0500 Subject: [PATCH] Fix return values --- lib/graphql/schema.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/graphql/schema.rb b/lib/graphql/schema.rb index a35d396993..f8b3fd45fb 100644 --- a/lib/graphql/schema.rb +++ b/lib/graphql/schema.rb @@ -459,6 +459,7 @@ def query(new_query_object = nil, &lazy_load_block) elsif @query_object.is_a?(Proc) @query_object = @query_object.call self.visibility&.query_configured(@query_object) + @query_object else @query_object || find_inherited_value(:query) end @@ -492,6 +493,7 @@ def mutation(new_mutation_object = nil, &lazy_load_block) elsif @mutation_object.is_a?(Proc) @mutation_object = @mutation_object.call self.visibility&.mutation_configured(@query_object) + @mutation_object else @mutation_object || find_inherited_value(:mutation) end @@ -512,7 +514,7 @@ def subscription(new_subscription_object = nil, &lazy_load_block) raise GraphQL::Error, "Second definition of `subscription(...)` (#{dup_defn.inspect}) is invalid, already configured with #{@subscription_object.inspect}" elsif use_visibility_profile? if block_given? - @subscription_object = new_subscription_object + @subscription_object = lazy_load_block else @subscription_object = new_subscription_object self.visibility.subscription_configured(@subscription_object) @@ -527,6 +529,7 @@ def subscription(new_subscription_object = nil, &lazy_load_block) elsif @subscription_object.is_a?(Proc) @subscription_object = @subscription_object.call add_subscription_extension_if_necessary + self.visibility.subscription_configured(@subscription_object) @subscription_object else @subscription_object || find_inherited_value(:subscription) @@ -712,17 +715,22 @@ def get_fields(type, context = GraphQL::Query::NullContext.instance) type.fields(context) end + # Pass a custom introspection module here to use it for this schema. + # @param new_introspection_namespace [Module] If given, use this module for custom introspection on the schema + # @return [Module, nil] The configured namespace, if there is one def introspection(new_introspection_namespace = nil) if new_introspection_namespace @introspection = new_introspection_namespace # reset this cached value: @introspection_system = nil introspection_system + @introspection else @introspection || find_inherited_value(:introspection) end end + # @return [Schema::IntrospectionSystem] Based on {introspection} def introspection_system if !@introspection_system @introspection_system = Schema::IntrospectionSystem.new(self)