@@ -23,21 +23,14 @@ def mount_graphql_devise_for(resource, options = {})
2323 ]
2424 ) . validate!
2525
26- custom_operations = options . fetch ( :operations , { } )
27- skipped_operations = options . fetch ( :skip , [ ] )
28- only_operations = options . fetch ( :only , [ ] )
29- additional_mutations = options . fetch ( :additional_mutations , { } )
30- additional_queries = options . fetch ( :additional_queries , { } )
31- path = options . fetch ( :at , '/graphql_auth' )
32- mapping_name = resource . underscore . tr ( '/' , '_' ) . to_sym
33- authenticatable_type = options [ :authenticatable_type ] . presence ||
26+ authenticatable_type = clean_options . authenticatable_type . presence ||
3427 "Types::#{ resource } Type" . safe_constantize ||
3528 GraphqlDevise ::Types ::AuthenticatableType
3629
3730 param_operations = {
38- custom : custom_operations ,
39- only : only_operations ,
40- skipped : skipped_operations
31+ custom : clean_options . operations ,
32+ only : clean_options . only ,
33+ skipped : clean_options . skip
4134 }
4235
4336 devise_for (
@@ -63,28 +56,30 @@ def mount_graphql_devise_for(resource, options = {})
6356 authenticatable_type : authenticatable_type
6457 )
6558
66- prepared_mutations . merge ( additional_mutations ) . each do |action , mutation |
59+ all_mutations = prepared_mutations . merge ( clean_options . additional_mutations )
60+ all_mutations . each do |action , mutation |
6761 GraphqlDevise ::Types ::MutationType . field ( action , mutation : mutation )
6862 end
6963
70- if ( prepared_mutations . present? || additional_mutations . present? ) &&
64+ if all_mutations . present? &&
7165 ( Gem ::Version . new ( GraphQL ::VERSION ) < Gem ::Version . new ( '1.10.0' ) || GraphqlDevise ::Schema . mutation . nil? )
7266 GraphqlDevise ::Schema . mutation ( GraphqlDevise ::Types ::MutationType )
7367 end
7468
75- prepared_queries . merge ( additional_queries ) . each do |action , resolver |
69+ all_queries = prepared_queries . merge ( clean_options . additional_queries )
70+ all_queries . each do |action , resolver |
7671 GraphqlDevise ::Types ::QueryType . field ( action , resolver : resolver )
7772 end
7873
79- if ( prepared_queries . blank? || additional_queries . present? ) && GraphqlDevise ::Types ::QueryType . fields . blank?
74+ if all_queries . present? && GraphqlDevise ::Types ::QueryType . fields . blank?
8075 GraphqlDevise ::Types ::QueryType . field ( :dummy , resolver : GraphqlDevise ::Resolvers ::Dummy )
8176 end
8277
8378 Devise . mailer . helper ( GraphqlDevise ::MailerHelper )
8479
85- devise_scope mapping_name do
86- post path , to : 'graphql_devise/graphql#auth'
87- get path , to : 'graphql_devise/graphql#auth'
80+ devise_scope resource . underscore . tr ( '/' , '_' ) . to_sym do
81+ post clean_options . at , to : 'graphql_devise/graphql#auth'
82+ get clean_options . at , to : 'graphql_devise/graphql#auth'
8883 end
8984 end
9085 end
0 commit comments