Skip to content

Commit

Permalink
Merge pull request #54 from graphql-devise/fix-alias-concerns
Browse files Browse the repository at this point in the history
Fix concern aliases
  • Loading branch information
mcelicalderon committed Dec 26, 2019
2 parents 3310c33 + b13d83a commit e033121
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,16 @@ class User < ApplicationRecord
:confirmable

# including after calling the `devise` method is important.
# include DeviseTokenAuth::Concerns::User # is also valid (generator includes this one).
include GraphqlDevise::Concerns::Model
end
```

The install generator can do this for you if you specify the `user_class` option.
See [Installation](#Installation) for details.
The generator will include a different module in your model, `DeviseTokenAuth::Concerns::User` which is also correct,
we just made an alias on our namespace for consistency and possible extension.
Generators have to be updated to generate our module.

### Customizing Email Templates
The approach of this gem is a bit different from DeviseTokenAuth. We have placed our templates in `app/views/graphql_devise/mailer`,
Expand All @@ -145,6 +149,9 @@ In our example our model is `User`, so it would look like this:
# app/controllers/my_controller.rb

class MyController < ApplicationController
# include DeviseTokenAuth::Concerns::SetUserByToken # is also valid (generator includes this one).
include GraphqlDevise::Concerns::SetUserByToken

before_action :authenticate_user!

def my_action
Expand All @@ -155,6 +162,9 @@ end

The install generator can do this for you because it executes DTA installer.
See [Installation](#Installation) for details.
The generator will include a different module in your model, `DeviseTokenAuth::Concerns::SetUserByToken` which is also correct,
we just made an alias on our namespace for consistency and possible extension.
Generators have to be updated to generate our module.

### Making Requests
Here is a list of the available mutations and queries assuming your mounted model is `User`.
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/graphql_devise/concerns/set_user_by_token.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'devise_token_auth/concerns/set_user_by_token'

module GraphqlDevise
module Concerns
SetUserByToken = DeviseTokenAuth::Concerns::SetUserByToken
Expand Down
2 changes: 0 additions & 2 deletions app/models/graphql_devise/concerns/model.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'devise_token_auth/concerns/user'

module GraphqlDevise
module Concerns
Model = DeviseTokenAuth::Concerns::User
Expand Down

0 comments on commit e033121

Please sign in to comment.