Skip to content

Commit c21aa0d

Browse files
aaronamcelicalderon
authored andcommitted
Set standard to use authenticatable per Devise's coding standard. (#46)
* Set standard to use authenticatable per Devise's coding standard. * Some styling changes per @mcelicalderon's request.
1 parent 77d5f9b commit c21aa0d

20 files changed

Lines changed: 38 additions & 38 deletions

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Rails.application.routes.draw do
6161
mount_graphql_devise_for(
6262
'User',
6363
at: 'api/v1',
64-
authenticable_type: Types::MyCustomUserType,
64+
authenticatable_type: Types::MyCustomUserType,
6565
operations: {
6666
login: Mutations::Login
6767
},
@@ -81,8 +81,8 @@ and [queries](https://github.com/graphql-devise/graphql_devise/blob/b5985036e01e
8181
All mutations and queries are built so you can extend default behavior just by extending
8282
our default classes and yielding your customized code after calling `super`, example
8383
[here](https://github.com/graphql-devise/graphql_devise/blob/b5985036e01ea064e43e457b4f0c8516f172471c/spec/dummy/app/graphql/mutations/login.rb#L6).
84-
1. `authenticable_type`: By default, the gem will add an `authenticable` field to every mutation
85-
and an `authenticable` type to every query. Gem will try to use `Types::<model>Type` by
84+
1. `authenticatable_type`: By default, the gem will add an `authenticatable` field to every mutation
85+
and an `authenticatable` type to every query. Gem will try to use `Types::<model>Type` by
8686
default, so in our example you could define `Types::UserType` and every query and mutation
8787
will use it. But, you can override this type with this option like in the example.
8888
1. `skip`: An array of the operations that should not be available in the authentication schema. All these operations are
@@ -170,7 +170,7 @@ Here is a list of the available mutations and queries assuming your mounted mode
170170
1. `userSendResetPassword(email: String!, redirectUrl: String!): UserSendReserPasswordPayload`
171171
1. `userResendConfirmation(email: String!, redirectUrl: String!): UserResendConfirmationPayload`
172172

173-
The `UserResendConfirmationPayload` will return the `authenticable` resource that was sent the confirmation instructions but also has a `message: String!` that can be used to notify a user what to do after the instructions were sent to them
173+
The `UserResendConfirmationPayload` will return the `authenticatable` resource that was sent the confirmation instructions but also has a `message: String!` that can be used to notify a user what to do after the instructions were sent to them
174174

175175
#### Queries
176176
1. `userConfirmAccount(confirmationToken: String!, redirectUrl: String!): User`

app/graphql/graphql_devise/mutations/login.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def resolve(email:, password:)
1717

1818
yield resource if block_given?
1919

20-
{ authenticable: resource}
20+
{ authenticatable: resource}
2121
elsif resource && !active_for_authentication?(resource)
2222
if locked?(resource)
2323
raise_user_error(I18n.t('graphql_devise.mailer.unlock_instructions.account_lock_msg'))

app/graphql/graphql_devise/mutations/logout.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def resolve
1010

1111
yield current_resource if block_given?
1212

13-
{ authenticable: current_resource }
13+
{ authenticatable: current_resource }
1414
else
1515
raise_user_error(I18n.t('graphql_devise.user_not_found'))
1616
end

app/graphql/graphql_devise/mutations/resend_confirmation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def resolve(email:, redirect_url:)
2020
)
2121

2222
{
23-
authenticable: resource,
23+
authenticatable: resource,
2424
message: I18n.t('graphql_devise.confirmations.send_instructions', email: email)
2525
}
2626
else

app/graphql/graphql_devise/mutations/send_password_reset.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def resolve(email:, redirect_url:)
1717
)
1818

1919
if resource.errors.empty?
20-
{ authenticable: resource }
20+
{ authenticatable: resource }
2121
else
2222
raise_user_error_list(I18n.t('graphql_devise.invalid_resource'), errors: resource.errors.full_messages)
2323
end

app/graphql/graphql_devise/mutations/sign_up.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def resolve(confirm_success_url: nil, **attrs)
3333

3434
set_auth_headers(resource) if resource.active_for_authentication?
3535

36-
{ authenticable: resource }
36+
{ authenticatable: resource }
3737
else
3838
clean_up_passwords(resource)
3939
raise_user_error_list(

app/graphql/graphql_devise/mutations/update_password.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def resolve(current_password: nil, **attrs)
2020

2121
yield current_resource if block_given?
2222

23-
{ authenticable: current_resource }
23+
{ authenticatable: current_resource }
2424
else
2525
raise_user_error_list(
2626
I18n.t('graphql_devise.passwords.update_password_error'),

app/graphql/graphql_devise/resolvers/confirm_account.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def resolve(confirmation_token:, redirect_url:)
2525
end
2626

2727
controller.redirect_to(redirect_to_link)
28-
{ authenticable: resource }
28+
{ authenticatable: resource }
2929
else
3030
raise_user_error(I18n.t('graphql_devise.confirmations.invalid_token'))
3131
end

app/graphql/graphql_devise/types/authenticable_type.rb renamed to app/graphql/graphql_devise/types/authenticatable_type.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module GraphqlDevise
22
module Types
3-
class AuthenticableType < GraphQL::Schema::Object
3+
class AuthenticatableType < GraphQL::Schema::Object
44
field :email, String, null: false
55
end
66
end

lib/graphql_devise/rails/routes.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def mount_graphql_devise_for(resource, opts = {})
3939
skip: [:sessions, :registrations, :passwords, :confirmations, :omniauth_callbacks, :unlocks]
4040
)
4141

42-
authenticable_type = opts[:authenticable_type] ||
43-
"Types::#{resource}Type".safe_constantize ||
44-
GraphqlDevise::Types::AuthenticableType
42+
authenticatable_type = opts[:authenticatable_type] ||
43+
"Types::#{resource}Type".safe_constantize ||
44+
GraphqlDevise::Types::AuthenticatableType
4545

4646
used_mutations = if only_operations.present?
4747
default_mutations.slice(*only_operations)
@@ -54,7 +54,7 @@ def mount_graphql_devise_for(resource, opts = {})
5454
else
5555
new_mutation = Class.new(mutation)
5656
new_mutation.graphql_name("#{resource}#{action.to_s.camelize(:upper)}")
57-
new_mutation.field(:authenticable, authenticable_type, null: true)
57+
new_mutation.field(:authenticatable, authenticatable_type, null: true)
5858

5959
new_mutation
6060
end
@@ -74,7 +74,7 @@ def mount_graphql_devise_for(resource, opts = {})
7474
else
7575
new_query = Class.new(query)
7676
new_query.graphql_name("#{resource}#{action.to_s.camelize(:upper)}")
77-
new_query.type(authenticable_type, null: true)
77+
new_query.type(authenticatable_type, null: true)
7878

7979
new_query
8080
end

0 commit comments

Comments
 (0)