@@ -25,17 +25,25 @@ def mount_graphql_devise_for(resource, options = {})
2525 ]
2626 ) . validate!
2727
28- authenticatable_type = clean_options . authenticatable_type . presence ||
29- "Types::#{ resource } Type" . safe_constantize ||
30- GraphqlDevise ::Types ::AuthenticatableType
31-
3228 devise_for (
3329 resource . pluralize . underscore . tr ( '/' , '_' ) . to_sym ,
3430 module : :devise ,
3531 class_name : resource ,
3632 skip : DEVISE_OPERATIONS
3733 )
3834
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
39+
40+ # Avoid routes reload done by Devise
41+ return if GraphqlDevise . resource_mounted? ( resource )
42+
43+ authenticatable_type = clean_options . authenticatable_type . presence ||
44+ "Types::#{ resource } Type" . safe_constantize ||
45+ GraphqlDevise ::Types ::AuthenticatableType
46+
3947 prepared_mutations = GraphqlDevise ::MountMethod ::OperationPreparer . new (
4048 resource : resource ,
4149 custom : clean_options . operations ,
@@ -66,10 +74,7 @@ def mount_graphql_devise_for(resource, options = {})
6674
6775 Devise . mailer . helper ( GraphqlDevise ::MailerHelper )
6876
69- devise_scope resource . underscore . tr ( '/' , '_' ) . to_sym do
70- post clean_options . at , to : 'graphql_devise/graphql#auth'
71- get clean_options . at , to : 'graphql_devise/graphql#auth'
72- end
77+ GraphqlDevise . mount_resource ( resource )
7378 end
7479 end
7580end
0 commit comments