@@ -12,6 +12,7 @@ class Mapper
1212
1313 def mount_graphql_devise_for ( resource , options = { } )
1414 default_operations = GraphqlDevise ::DefaultOperations ::MUTATIONS . merge ( GraphqlDevise ::DefaultOperations ::QUERIES )
15+ mapping_name = resource . underscore . tr ( '/' , '_' ) . to_sym
1516
1617 # clean_options responds to all keys defined in GraphqlDevise::MountMethod::SUPPORTED_OPTIONS
1718 clean_options = GraphqlDevise ::MountMethod ::OptionSanitizer . new ( options ) . call!
@@ -32,20 +33,18 @@ def mount_graphql_devise_for(resource, options = {})
3233 skip : DEVISE_OPERATIONS
3334 )
3435
35- devise_scope resource . underscore . tr ( '/' , '_' ) . to_sym do
36- post clean_options . at , to : 'graphql_devise/graphql#auth'
37- get clean_options . at , to : 'graphql_devise/graphql#auth'
38- end
36+ post clean_options . at , to : 'graphql_devise/graphql#auth'
37+ get clean_options . at , to : 'graphql_devise/graphql#auth'
3938
4039 # Avoid routes reload done by Devise
41- return if GraphqlDevise . resource_mounted? ( resource )
40+ return if GraphqlDevise . resource_mounted? ( mapping_name )
4241
4342 authenticatable_type = clean_options . authenticatable_type . presence ||
4443 "Types::#{ resource } Type" . safe_constantize ||
4544 GraphqlDevise ::Types ::AuthenticatableType
4645
4746 prepared_mutations = GraphqlDevise ::MountMethod ::OperationPreparer . new (
48- resource : resource ,
47+ mapping_name : mapping_name ,
4948 custom : clean_options . operations ,
5049 additional_operations : clean_options . additional_mutations ,
5150 preparer : GraphqlDevise ::MountMethod ::OperationPreparers ::MutationFieldSetter . new ( authenticatable_type ) ,
@@ -59,7 +58,7 @@ def mount_graphql_devise_for(resource, options = {})
5958 end
6059
6160 prepared_queries = GraphqlDevise ::MountMethod ::OperationPreparer . new (
62- resource : resource ,
61+ mapping_name : mapping_name ,
6362 custom : clean_options . operations ,
6463 additional_operations : clean_options . additional_queries ,
6564 preparer : GraphqlDevise ::MountMethod ::OperationPreparers ::ResolverTypeSetter . new ( authenticatable_type ) ,
@@ -72,9 +71,9 @@ def mount_graphql_devise_for(resource, options = {})
7271 GraphqlDevise ::Types ::QueryType . field ( action , resolver : resolver )
7372 end
7473
75- Devise . mailer . helper ( GraphqlDevise :: MailerHelper )
74+ GraphqlDevise . add_mapping ( mapping_name , resource . constantize )
7675
77- GraphqlDevise . mount_resource ( resource )
76+ Devise . mailer . helper ( GraphqlDevise :: MailerHelper )
7877 end
7978 end
8079end
0 commit comments