Skip to content

Commit 605556e

Browse files
committed
* remove required for firstname and lastname
* remove devise-jwt replace with graphql-auth * use rails6 branch of graphql-auth * add rubocop as gem * remove unused mutations because we use graphql-auth * remove everything devise-jwt related * remove framework defaults * remove unused specs in graphqlcontroller
1 parent 5c15af5 commit 605556e

38 files changed

+164
-830
lines changed

Gemfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ gem 'pg'
1313

1414
gem 'bcrypt', '~> 3.1.7' # Use ActiveModel has_secure_password
1515
gem 'devise' # Use devise as authentication module
16-
gem 'devise-jwt', '~> 0.5.8' # Use JWT token authentication with devise
1716
gem 'graphql'
17+
gem 'graphql-auth', git: '[email protected]:simonfranzen/graphql-auth.git', branch: 'rails6'
1818
gem 'graphql-errors'
1919
gem 'rack-cors'
20+
2021
# gem 'graphiql-rails', group: :development
2122

2223
# Use Puma as the app server
@@ -65,6 +66,7 @@ group :development do
6566
gem 'rubocop-performance' # speed up rubocop
6667
gem 'rubocop-rails' # rubocop for rails
6768
gem 'rubocop-rspec' # rubocop for rspec
69+
gem 'rubocop' # rubocop for linting ruby code
6870
gem 'spring'
6971
gem 'spring-watcher-listen', '~> 2.0.0'
7072
end

Gemfile.lock

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
GIT
2+
remote: [email protected]:simonfranzen/graphql-auth.git
3+
revision: 087b1d8f30052a0b62654e6975e9f8e2b8d8cee7
4+
branch: rails6
5+
specs:
6+
graphql-auth (0.7.1)
7+
devise (~> 4.6, >= 4.6.2)
8+
graphql (~> 1.9, >= 1.9.6)
9+
jwt (~> 2.1)
10+
rails (~> 6.0)
11+
112
GEM
213
remote: https://rubygems.org/
314
specs:
@@ -72,25 +83,12 @@ GEM
7283
railties (>= 4.1.0)
7384
responders
7485
warden (~> 1.2.3)
75-
devise-jwt (0.5.9)
76-
devise (~> 4.0)
77-
warden-jwt_auth (~> 0.3.6)
7886
diff-lcs (1.3)
7987
docile (1.3.2)
8088
dotenv (2.7.2)
8189
dotenv-rails (2.7.2)
8290
dotenv (= 2.7.2)
8391
railties (>= 3.2, < 6.1)
84-
dry-auto_inject (0.6.1)
85-
dry-container (>= 0.3.4)
86-
dry-configurable (0.8.3)
87-
concurrent-ruby (~> 1.0)
88-
dry-core (~> 0.4, >= 0.4.7)
89-
dry-container (0.7.1)
90-
concurrent-ruby (~> 1.0)
91-
dry-configurable (~> 0.1, >= 0.1.3)
92-
dry-core (0.4.7)
93-
concurrent-ruby (~> 1.0)
9492
equatable (0.6.0)
9593
erubi (1.9.0)
9694
factory_bot (5.0.2)
@@ -266,11 +264,6 @@ GEM
266264
unicode_utils (1.4.0)
267265
warden (1.2.8)
268266
rack (>= 2.0.6)
269-
warden-jwt_auth (0.3.6)
270-
dry-auto_inject (~> 0.6)
271-
dry-configurable (~> 0.8)
272-
jwt (~> 2.1)
273-
warden (~> 1.2)
274267
websocket-driver (0.7.3)
275268
websocket-extensions (>= 0.1.0)
276269
websocket-extensions (0.1.5)
@@ -286,11 +279,11 @@ DEPENDENCIES
286279
byebug
287280
database_cleaner (~> 1.6)
288281
devise
289-
devise-jwt (~> 0.5.8)
290282
dotenv-rails
291283
factory_bot_rails
292284
faker (~> 1.8)
293285
graphql
286+
graphql-auth!
294287
graphql-errors
295288
listen (>= 3.0.5, < 3.2)
296289
pg
@@ -299,6 +292,7 @@ DEPENDENCIES
299292
rails (~> 6.0.3)
300293
rails-controller-testing
301294
rspec-rails (~> 3.8)
295+
rubocop
302296
rubocop-performance
303297
rubocop-rails
304298
rubocop-rspec

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ The app uses a postgresql database. It implements the connector with the gem `pg
6363
The app uses [devise](https://github.com/plataformatec/devise)'s logic for authentication. Emails are currently disabled in the environment settings.
6464

6565
### 3. JSON Web Token
66-
[devise-jwt](https://github.com/waiting-for-dev/devise-jwt) is a devise extension which uses JWT tokens for user authentication. It follows [secure by default](https://en.wikipedia.org/wiki/Secure_by_default) principle.
66+
[graphql-auth](https://github.com/o2web/graphql-auth) is a graphql/devise extension which uses JWT tokens for user authentication. It follows [secure by default](https://en.wikipedia.org/wiki/Secure_by_default) principle.
6767

6868
### 4. GraphQL
6969
[graphql-ruby](https://github.com/rmosolgo/graphql-ruby) is a Ruby implementation of GraphQL. Sadly it's not 100% open source, but with the free version allows you amazing things to do. See the [Getting Started Guide](https://graphql-ruby.org/) and the current implementations in this project under `app/graphql/`.

app/controllers/graphql_controller.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
# GraphQL API entry point
44
class GraphqlController < ApplicationController
5+
include Graphql::AuthHelper
6+
57
# Executes the graphql request
68
def execute
79
query, variables, operation_name = read_query_params()
8-
context = set_context()
910
result = GraphqlSchema.execute(
1011
query,
1112
variables: variables,
@@ -29,13 +30,6 @@ def read_query_params
2930
]
3031
end
3132

32-
def set_context
33-
{
34-
current_user: current_user
35-
# login: method(:sign_in)
36-
}
37-
end
38-
3933
# Handle form data, JSON body, or a blank value
4034
def ensure_hash(ambiguous_param)
4135
case ambiguous_param

app/graphql/mutations/user/login.rb

Lines changed: 0 additions & 24 deletions
This file was deleted.

app/graphql/mutations/user/logout.rb

Lines changed: 0 additions & 21 deletions
This file was deleted.

app/graphql/mutations/user/resend_unlock_instructions.rb

Lines changed: 0 additions & 20 deletions
This file was deleted.

app/graphql/mutations/user/reset_password.rb

Lines changed: 0 additions & 22 deletions
This file was deleted.

app/graphql/mutations/user/send_reset_password_instructions.rb

Lines changed: 0 additions & 21 deletions
This file was deleted.

app/graphql/mutations/user/sign_up.rb

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)