@@ -845,7 +845,7 @@ class << self
845845 # - Cause the Schema instance to be created, if it hasn't been created yet
846846 # - Delegate to that instance
847847 # Eventually, the methods will be moved into this class, removing the need for the singleton.
848- def_delegators :graphql_definition ,
848+ def_delegators :deprecated_graphql_definition ,
849849 # Execution
850850 :execution_strategy_for_operation ,
851851 # Configuration
@@ -854,6 +854,10 @@ class << self
854854 :id_from_object= , :object_from_id= ,
855855 :remove_handler
856856
857+ def deprecated_graphql_definition
858+ graphql_definition ( silence_deprecation_warning : true )
859+ end
860+
857861 # @return [GraphQL::Subscriptions]
858862 attr_accessor :subscriptions
859863
@@ -896,8 +900,15 @@ def find(path)
896900 @find_cache [ path ] ||= @finder . find ( path )
897901 end
898902
899- def graphql_definition
900- @graphql_definition ||= to_graphql
903+ def graphql_definition ( silence_deprecation_warning : false )
904+ @graphql_definition ||= begin
905+ unless silence_deprecation_warning
906+ message = "Legacy `.graphql_definition` objects are deprecated and will be removed in GraphQL-Ruby 2.0. Use a class-based definition instead."
907+ caller_message = "\n \n Called on #{ self . inspect } from:\n #{ caller ( 1 , 25 ) . map { |l | " #{ l } " } . join ( "\n " ) } "
908+ GraphQL ::Deprecation . warn ( message + caller_message )
909+ end
910+ to_graphql
911+ end
901912 end
902913
903914 def default_filter
@@ -932,16 +943,16 @@ def plugins
932943 def to_graphql
933944 schema_defn = self . new
934945 schema_defn . raise_definition_error = true
935- schema_defn . query = query && query . graphql_definition
936- schema_defn . mutation = mutation && mutation . graphql_definition
937- schema_defn . subscription = subscription && subscription . graphql_definition
946+ schema_defn . query = query && query . graphql_definition ( silence_deprecation_warning : true )
947+ schema_defn . mutation = mutation && mutation . graphql_definition ( silence_deprecation_warning : true )
948+ schema_defn . subscription = subscription && subscription . graphql_definition ( silence_deprecation_warning : true )
938949 schema_defn . validate_timeout = validate_timeout
939950 schema_defn . validate_max_errors = validate_max_errors
940951 schema_defn . max_complexity = max_complexity
941952 schema_defn . error_bubbling = error_bubbling
942953 schema_defn . max_depth = max_depth
943954 schema_defn . default_max_page_size = default_max_page_size
944- schema_defn . orphan_types = orphan_types . map ( & :graphql_definition )
955+ schema_defn . orphan_types = orphan_types . map { | t | t . graphql_definition ( silence_deprecation_warning : true ) }
945956 schema_defn . disable_introspection_entry_points = disable_introspection_entry_points?
946957 schema_defn . disable_schema_introspection_entry_point = disable_schema_introspection_entry_point?
947958 schema_defn . disable_type_introspection_entry_point = disable_type_introspection_entry_point?
0 commit comments