@@ -13,32 +13,23 @@ def call(query, mutation)
1313 # clean_options responds to all keys defined in GraphqlDevise::MountMethod::SUPPORTED_OPTIONS
1414 clean_options = GraphqlDevise ::MountMethod ::OptionSanitizer . new ( @options ) . call!
1515
16- model = if @resource . is_a? ( String )
17- ActiveSupport ::Deprecation . warn ( <<-DEPRECATION . strip_heredoc , caller )
18- Providing a String as the model you want to mount is deprecated and will be removed in a future version of
19- this gem. Please use the actual model constant instead.
20-
21- EXAMPLE
22-
23- GraphqlDevise::ResourceLoader.new(User) # instead of GraphqlDevise::ResourceLoader.new('User')
24-
25- mount_graphql_devise_for User # instead of mount_graphql_devise_for 'User'
26- DEPRECATION
27- @resource . constantize
28- else
29- @resource
16+ unless @resource . is_a? ( Class )
17+ raise (
18+ GraphqlDevise ::InvalidMountOptionsError ,
19+ 'A class must be provided when mounting a model. String values are no longer supported.'
20+ )
3021 end
3122
3223 # Necesary when mounting a resource via route file as Devise forces the reloading of routes
33- return clean_options if GraphqlDevise . resource_mounted? ( model ) && @routing
24+ return clean_options if GraphqlDevise . resource_mounted? ( @resource ) && @routing
3425
3526 validate_options! ( clean_options )
3627
3728 authenticatable_type = clean_options . authenticatable_type . presence ||
3829 "Types::#{ @resource } Type" . safe_constantize ||
3930 GraphqlDevise ::Types ::AuthenticatableType
4031
41- prepared_mutations = prepare_mutations ( model , clean_options , authenticatable_type )
32+ prepared_mutations = prepare_mutations ( @resource , clean_options , authenticatable_type )
4233
4334 if prepared_mutations . any? && mutation . blank?
4435 raise GraphqlDevise ::Error , 'You need to provide a mutation type unless all mutations are skipped'
@@ -48,7 +39,7 @@ def call(query, mutation)
4839 mutation . field ( action , mutation : prepared_mutation , authenticate : false )
4940 end
5041
51- prepared_resolvers = prepare_resolvers ( model , clean_options , authenticatable_type )
42+ prepared_resolvers = prepare_resolvers ( @resource , clean_options , authenticatable_type )
5243
5344 if prepared_resolvers . any? && query . blank?
5445 raise GraphqlDevise ::Error , 'You need to provide a query type unless all queries are skipped'
@@ -59,7 +50,7 @@ def call(query, mutation)
5950 end
6051
6152 GraphqlDevise . add_mapping ( GraphqlDevise . to_mapping_name ( @resource ) . to_sym , @resource )
62- GraphqlDevise . mount_resource ( model ) if @routing
53+ GraphqlDevise . mount_resource ( @resource ) if @routing
6354
6455 clean_options
6556 end
0 commit comments